- Engineering
- Computer Science
- i have an array list and i want to print...
Question: i have an array list and i want to print...
Question details
I have an array list and I want to print all of it's components. I looked at different ways to do it but nothing is working for me. It keeps giving me an address to where the object is located. The array list contains students with a name, id Number, and date.
This is the array list:
static ArrayList <Student> regStudents = new ArrayList<Student>();
And this is the two ways I attempted to print it:
for(int i = 0; i < regStudents.size(); i++) {
System.out.println(regStudents.get(i).getName());
} // Trying to print individual names and wont work
System.out.println(Arrays.toString(regStudents.(list.toArray()));
// Trying to print all the elements. Still wont work!!!
Please Help
Solution by an expert tutor
