Answer the question
In order to leave comments, you need to log in
How to write such a Swift construct in Java?
How to write in Java? Here is an example in Swift:
private let sections: [(title: String, description: String)] = [(title: "title1", description: "description1"), (title: "title2", description: "description2")]
cell.titleLabel?.text = self.sections[(indexPath as NSIndexPath).row].title
cell.descriptionLabel?.text = self.sections[(indexPath as NSIndexPath).row].description
Answer the question
In order to leave comments, you need to log in
public class Section {
private String title;
private String description;
public Section(String title, String description) {
setTitle(title);
setDescription(description);
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
}
List<Section> sections = new ArrayList<>();
sections.add(new Section("title1", "description1"));
sections.add(new Section("title2", "description2"));
(corrected)
ok then
@Getter
@Setter
@AllArgsConstructor
public class Data {
private String title;
private String description;
}
private List<Data> sections = new ArrayList<>();
sections.add(new Data("title1", "description1"));
sections.add(new Data("title2", "description2"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question