最简单的问题 找不到符号。
import java.util.*;
class MyArray{
private int N1;
private int N2;
private int N3;
private int N4;
}
public class yuyan{
public static void main(String args[]){
MyArray Mothy = new MyArray(10,9,8,7);
System.out.println(Mothy);
}
}
编译的时候说找不到符号
是我路径不对吗?
------解决方案--------------------MyArray Mothy = new MyArray(10,9,8,7);实例时调用MyArray 类的带4个参数的构造器,你没定义啊
------解决方案--------------------MyArray Mothy = new MyArray(10,9,8,7);
你的myArray 都没有MyArray(10,9,8,7)这样的构件器,怎么可以这样new?
先个默认构件器,再加上一个构件器
public MyArray(int a,int b,int c,int d){
N1=a;
N2=B;
N3=C;
N4=D;
}
------解决方案--------------------你是想这样吗?
import java.util.*;
class MyArray{
private int N1;
private int N2;
private int N3;
private int N4;
public MyArray(int i,int j,int k,int n){
N1=i;
N2=j;
N3=k;
N4=n;
}
}
public class yuyan{
public static void main(String args[]){
MyArray Mothy = new MyArray(10,9,8,7);
System.out.println(Mothy);
}
}