Answer the question
In order to leave comments, you need to log in
How to access from ArrayList object properties in JAVA?
Kind
In the AS3 language, I know how to get access, but it doesn’t work by analogy with JAVA. Let there be a Label, it has an id and it (Label) is added to the ArrayList. How can I find out what is stored in id? It is necessary to compare the ID with those in the database
if (resultSet.getInt(1) == arrayList.get(i).getId){}//по аналогии с as3
//arrayList[i].getId - так бы выглядел доступ в as3
if (resultSet.getInt(1) != arrayList.get(i).getId()) {
Label label = new Label();
label.setId(String.valueOf(resultSet.getInt("id")));
label.setText(resultSet.getString("nameProduct"));
arrayList.add(label);
root.getChildren().add(label);
}
Answer the question
In order to leave comments, you need to log in
Well, probably for the Label method, if the field id is private, you need to write a getter
public class Lebel {
private long id;
public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question