所以我有这个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;
}
Run Code Online (Sandbox Code Playgroud)
但是,我想知道如何在其他方法中使用该列表,我尝试了一些类似的东西
public void information(List<thegame>) {
System.out.print(thegame);
})
Run Code Online (Sandbox Code Playgroud)
我希望能够在其他方法中使用该列表,并能够显示它并修改它.我是Java的初学者.
所以我有一个名为User的java类,它包含一个像这样的构造函数:
public class User extends Visitor {
public User(String UName, String Ufname){
setName(UName);
setFname(Ufname);
}
}
Run Code Online (Sandbox Code Playgroud)
然后他的问题出现在我的另一个名为Admin的类中:
public class Admin extends User { //error "Implicit super constructor User() is undefined for default constructor. Must define an explicit constructor"
//public Admin() { } //tried to add empty constructor but error stays there
//}
public void manage_items() {
throw new UnsupportedOperationException();
}
public void manage_users() {
throw new UnsupportedOperationException();
}
}
Run Code Online (Sandbox Code Playgroud)
我收到的错误Implicit super constructor User() is undefined for default constructor. Must …
我正在寻找能够将 Python 变量中的内容与 SQLite 查询中的内容进行比较的方法。
例如:
num = input ("enter a number")
cur.execute("SELECT a.Name,a.Number FROM Ads a WHERE a.Number = (num)")
row = cur.fetchone()
while row:
print(row)
row = cur.fetchone()
Run Code Online (Sandbox Code Playgroud)
线路cur.execute不行了 我不知道如何能够通过 SQlite 查询将 Python 变量的内容与 SQLite 数据库中的数据进行比较。
我有一个像这样的int的Scanner
Scanner telnumscanner = new Scanner(System.in);
System.out.print("Entrez phone number: \n");
int telnum = telnumscanner.nextInt();
Run Code Online (Sandbox Code Playgroud)
我在那里输入了一个电话号码样式(0000000000--10个数字)但是当我输入号码时,它会崩溃.
java ×3
methods ×2
arraylist ×1
constructor ×1
inheritance ×1
integer ×1
python ×1
return ×1
sqlite ×1
variables ×1