【发布时间】:2015-02-14 01:20:51
【问题描述】:
所以我有这个输入内容并将其放入数组列表的 java 代码:
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;
}
但是,我想知道如何在其他方法中使用列表,我尝试了一些类似的方法
public void information(List<thegame>) {
System.out.print(thegame);
})
我希望能够在其他方法中使用列表,并且能够显示和修改它。我是Java的初学者。
【问题讨论】:
标签: java methods arraylist return