+ 2
how do you print object values from ArrayList
After adding objects to an ArrayList, is there a way to print the values of the objects from the ArrayList? I have a class with getMake(), getModel(), and getPrice() but I don't know how to use them after adding the objects to the ArrayList. after adding the objects to the ArrayList, I'm trying to loop through the list and print the object values I saw toString might be a solution but I'm having difficulty adding it to my code Here is the link to my code https://code.sololearn.com/cG4k7bADF2L7 Appreciate any help
2 Respostas
+ 7
David
You have to make toString method
public String toString() {
return make + " : " + model + " : " + price;
}
+ 4
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ thank you AJ!! It works