use*_*296 0 java compiler-errors
我正在为商店做代码,这部分是为了让员工可以将手机添加到现有库存中.我无法弄清楚问题是什么,因为它不会编译并说"不兼容的类型",它标志着部分[name =""; type =""; color ="";]
这是驱动程序类的一部分:
//add new phone to stock
public void addPhone( ) {
Phone phone = new Phone ( itemsId, brand, price, name, type, colour);
Scanner scan = new Scanner(System.in);
String itemsId;
String brand;
double price;
String name;
String type;
String colour;
for (int counter=0; counter< 1; counter ++)
{
itemsId= " ";
brand=" ";
price=
name= " ";
type=" ";
colour=" ";
System.out.println("Enter itemsID: ");
itemsId= scan.nextLine();
System.out.println("Enter brand: ");
brand= scan.nextLine();
System.out.println("Enter price: ");
price= scan.nextdouble();
System.out.println("Enter name: ");
name= scan.nextLine();
System.out.println("Enter type: ");
type= scan.nextLine();
System.out.println("Enter colour: ");
colour= scan.nextLine();
}
phoneList.add(phone);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
78 次 |
| 最近记录: |