-1

I am storing 13 object in arraylist but if print arraylist then it shows address of array as [com.psl.beans.Student@e83912, com.psl.beans.Student@1fae3c6,com.psl.beans.Student@7ffe01, com.psl.beans.Student@fd13b5,com.psl.beans.Student@118f375, com.psl.beans.Student@117a8bd,com.psl.beans.Student@471e30, com.psl.beans.Student@10ef90c,com.psl.beans.Student@a32b, com.psl.beans.Student@1d8957f,com.psl.beans.Student@3ee284, com.psl.beans.Student@8965fb,com.psl.beans.Student@867e89]

but i want to see content of object in that list when i print list so is there any way to do this..

Mohit Shaha
  • 11
  • 1
  • 3

1 Answers1

1

Override the toString() method

Example

class Student {
    private String name;
    private String lastname;        

    @Override
    public String toString() {
        return this.name + " " + this.lastname;
    }
}

You should do the same with the attributes of your Student class and call the Student.toString() method each time you want to show its content