小编Phi*_*eil的帖子

在其他方法中使用List(arraylist)(java)

所以我有这个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的初学者.

java methods return arraylist

3
推荐指数
1
解决办法
100
查看次数

未定义的构造函数(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 …

java methods inheritance constructor

2
推荐指数
1
解决办法
944
查看次数

如何在 sqlite 查询中插入 Python 变量?

我正在寻找能够将 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 数据库中的数据进行比较。

python sqlite variables

2
推荐指数
1
解决办法
8014
查看次数

扫描仪更具特色?

我有一个像这样的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 integer java.util.scanner

0
推荐指数
1
解决办法
38
查看次数