日期:2014-05-20  浏览次数:20713 次

谁能帮我看看这段代码在myeclipse里无法run as的问题
class duotai {
int a;
int b;
public void fangfa1(int a, int b) {
  this.a = a;
this.b = b;
System.out.println(a + b);
}

public void fangfa2(int a, int b) {
this.a = a;
this.b = b;
System.out.println(a - b);
}
}

class anotherduotai extends duotai {

public void fangfa1(int a, int b) {
super.a=a;
super.b=b;
System.out.println(a * b);
}

public void fangfa3(int a, int b) {
super.a=a;
super.b=b;
if (b == 0)
System.out.println("b!=0");
else
System.out.println(a / b);

}
}

class test {
public static void main(String[] args) {
duotai dt = new duotai();
dt.fangfa1(8, 2);}}

------解决方案--------------------
怎么没看到public class呢,试试把
 class test {
 public static void main(String[] args) {
 duotai dt = new duotai();
 dt.fangfa1(8, 2);}}

改为
public class test {
 public static void main(String[] args) {
 duotai dt = new duotai();
 dt.fangfa1(8, 2);}}