The expected output of my index 0 Array list is the name and the number. But its showing weird result why?
fullcode here enter image description here
The expected output of my index 0 Array list is the name and the number. But its showing weird result why?
fullcode here enter image description here
Don't post images. Post the code. If you want to print arrays, then you should use Arrays.toString
method. Every element in the array should also have a toString
method. Here is an example:
class Student{
int id;
String name;
public Student(int id, String name){
this.id = id;
this.name = name;
}
@override
public String toString(){
return "Student " + name + ", with id: " + id;
}
}
Then use something like this in the main method:
ArrayList<Student> studentList = new ArrayList<>();
studentList.add(new Student(134, "Jake"));
studentList.add(new Student(435, "Mark"));
System.out.println(Arrays.toString(studentList));