我用java的医生为Linux来运行我的代码。 我一直运行到一堆错误最近运行这个简单的程序时。 代码编译罚款,但每当我运行java文件,我得到的错误; 静态错误:这里未定义的名称是我的代码; (我有两个文件,Square.java和SquareD.java)这里的Square.java
public class Square{
private String name;
private int y;
private int x;
public Square(String st,int x2,int y2){
name=st;
x=x2;
y=y2;
}
public int square(){
return x*x+y*y;
}
double a1=(double) x;
double a2=(double) y;
public double hypotenuse(double a1,double a2){
double sum = a1*a1+a2*a2;
return Math.sqrt(sum);
}
public int area(){
return x*y;
}
public String getName(){
return name;
}
}
这里的SquareD.java;
public class Square{
private String name;
private int y;
private int x;
public Square(String st,int x2,int y2){
name=st;
x=x2;
y=y2;
}
public int square(){
return x*x+y*y;
}
double a1=(double) x;
double a2=(double) y;
public double hypotenuse(double a1,double a2){
double sum = a1*a1+a2*a2;
return Math.sqrt(sum);
}
public int area(){
return x*y;
}
public String getName(){
return name;
}
}
Whever I型java Square.java
或java SquareD.java
在交互的窗口,我得到的,
静态错误:未定义的名称
我运行Ubuntu 11.10