a simple android program which accept a user id and user name, and store them inside an arrayList using a subclass called Student. There are 2 buttons, one of them record the information and the other one display them. The top button seem to work fine, but for the other one it display something that looks like the address instead of the actual data, what's the problem? Thanks
Asked
Active
Viewed 112 times
-2
-
Post your code here and you did not implement `toString` in your pojo. – Murat Karagöz Sep 18 '18 at 12:38
-
post your code please – Faiz Mir Sep 18 '18 at 12:43
-
you don't have getter for name. It should be `output.append(studetnList.get(i).getName())` – bakero98 Sep 18 '18 at 12:43
-
Please paste code instead of image – Jitendra A Sep 18 '18 at 12:48
2 Answers
1
Override Object.toString() in your Student class.
//Sample code
public String toString() {
return "id of the student:" + this.id + ",, "
+ "name of the student:" + this.name ;
}
For more info, see this answer

Jitendra A
- 1,568
- 10
- 18
-
U r welcome @omoisama, If the answer is satisfactory then pls accept it so that others with the same issues can benefit from it – Jitendra A Sep 18 '18 at 14:21
0
use this code for you funclist method
private void funclist(){
StringBuilder output = new StringBuilder();
for(int i=0;i<studentList.seize();i++){
output.append(studentList.get(i) + "\n");
}
}
this will convert your object to string or you can add
studentList.get(i).toString()
instead of your code.

Mehran Mahmoudkhani
- 406
- 6
- 20