求解。分开方法。总是报错啊、
package com.guoluqiang;import java.util.Scanner;
public class Test {
public void tese(){
Scanner sc = new Scanner(System.in);
Commodity s = new Commodity();
System.out.println("商品名称");
s.name = sc.next();
System.out.println("商品数量");
s.quantity = sc.next();
System.out.println("商品单价");
s.unit_price = sc.next();
System.out.println("商品单位");
s.unit = sc.next();
System.out.println("商品分类");
s.classify = sc.next();
System.out.print(s.name+" "+s.quantity+" "+s.unit_price+" "+s.unit+" "+s.classify+" ");
public void{这里总是报错啊。。。大神求解。
Commodity[] d = new Commodity[3];
for(int i = 0; i < 3; i++){
Commodity t = new Commodity();
System.out.println("商品颜色");
t.color = sc.next();
d[i] = t;
}
for(int j = 0; j < 3;j++){
System.out.print(d[j].color+" ");
}
}
}
public static void main(String[] args) {
Test s = new Test();
s.tese();
}
}
怎么分开啊。