对于在意大利的一些名字的声明和我在该领域的无知,我深表歉意,我是Java编程的新手。在处理项目时,我遇到了这个问题。我不太了解发生了什么事
public Prodotti mascheraInserimento() {
Prodotti p = new Prodotti(); // Prodotti is a class wich has 3 attributes ID_Prodotto, Prodotto, Quantita.
Scanner input = new Scanner(System.in); //calling Scanner
System.out.print("Prodotto :"); //with Prodotto I mean product
String prod = input.next(); //Getting the string value inserted by user
p.setProdotto(prod); //set the string value inserted as the attribute's value
System.out.print("Quantita : "); //with Quantita' I mean quantity
int qta = Integer.parseInt(input.next()); //Getting the string value inserted by user
p.setQuantita(qta); //set the string value inserted as the attribute's value
input.close(); //close scanner
return p;
}
我尝试更改一些代码行(例如“第9行”),并尝试擦除Scanner的.close()方法。它当然没有解决任何问题,所以我发布了实际的代码行。如果需要其余的代码,我会提供给您。