Reputation: 267
so I have this java code that input stuff and puts it into an array list:
public void adding() {
boolean loop = true;
ArrayList<Game> thegame = new ArrayList<Game>();
while(loop) {
Scanner agame = new Scanner(System.in);
System.out.print("name: \n");
String Cgame = agame.nextLine();
Scanner qty = new Scanner(System.in);
System.out.print("the qty: \n");
int CQty = qty.nextInt();
Console wertgame = new Console(Cgame,Cqty);
thegame.add(new Game(Cgame,Cqty));
System.out.println("continue?");
Scanner autre = new Scanner(System.in);
int continu = other.nextInt();
if(continu==1) {
}
else if(continu==2) {
Main.menu();
}
}
return thegame;
}
However,im wondering how to use the list in other methods,I tried some things like
public void information(List<thegame>) {
System.out.print(thegame);
})
I want to be able to use the list in other methods and be able to display it and also modify it.Im quite a beginner in Java.
Upvotes: 3
Views: 128
Reputation: 15698
You havent declared thegame
as parameter. Change
public void information(List<thegame>) {
System.out.print(thegame);
}}
to
public void information(List<Game> thegame) {
System.out.print(thegame);
}}
Upvotes: 6