Printing out information from an arraylist | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Printing out information from an arraylist

so i have this project (college homework) and i need to show the preview of the shopping car(elements, cost) but with the method i'm using i only get one of the items. help psl i add the link with the code https://drive.google.com/file/d/0B2WgC5JnH2wfbXhUUGc3WlVIS0k4SnA1WkpBTWxvbTF5bzlR/view?usp=drivesdk

7th Oct 2017, 4:08 AM
Juan Felipe Jaramillo
Juan Felipe Jaramillo - avatar
4 Answers
0
the arraylist class in java has already defined. tostring method. and you can use it in two ways: imagine your arraylist's name is list. use one of the options below System.out.print(list); System.out.print(list.toString());
7th Oct 2017, 12:37 PM
Amir Masoud Mostofinejad
Amir Masoud Mostofinejad - avatar
0
I did it but it shows only the codes of the videogames like this: modelo.videojuego@aszxd12 is there a way to print like the name, price and everything?
7th Oct 2017, 3:13 PM
Juan Felipe Jaramillo
Juan Felipe Jaramillo - avatar
0
you have to define a .toString method for you videogames class too
7th Oct 2017, 3:17 PM
Amir Masoud Mostofinejad
Amir Masoud Mostofinejad - avatar
0
this is another version. is working nicely till i insert the quantity and gives me a null pointer exception. any advice? https://drive.google.com/folderview?id=0B2WgC5JnH2wfUFZ0a2NOUkFGblk
7th Oct 2017, 8:06 PM
Juan Felipe Jaramillo
Juan Felipe Jaramillo - avatar