I want to print out the values of an array in a "for statement", but instead, it's printing the object address.
Person student = new Person();
Person [] students = new Person[10];
students[0] = student;
students[1] = student;
students[2] = student;
students[0].studentDetails("Abel Morris Ben", "Java Programming", 99);
students[1].studentDetails("Jane Doe", "Web Development", 85);
students[2].studentDetails("John Doe", "Ethical Hacking", 80);
for( int i=0; i <= 2; i++) {
System.out.println(students[i]);
}
It's is printing the object location instead:
Person@2a139a55
Person@2a139a55
Person@2a139a55