对象数组那里错了
package javaapplication1;class gouwu{
String name;
int danjia;
int shuliang;
int sum;
public void fff(int danjia,int shuliang, String name){
this.danjia=danjia;this.shuliang=shuliang;this.name=name;
}
public void gouwu(gouwu a[]){
for (int i=0;i<a.length;i++)
{
sum=sum+a[i].danjia*a[i].shuliang;
}
System.out.print(sum);
}
}
public class Main {
public static void main(String[] args) {
gouwu []a=new gouwu[3];
a[0].fff(1, 1, "a");
a[1].fff(2,2,"b");
a[2].fff(3, 3, "c");
gouwu b=new gouwu();
b.gouwu(a);
}
}
a[0].fff(1, 1, "a");
a[1].fff(2,2,"b");
说是这里有问题