public class A {
int a;
int b;
/** Creates a new instance of A */
public A() {
this(1,9);
}
public A(int aa,int bb){
a=aa;
b=bb;
}
}
int c;
public B(){
this(1,2,1);
}
public B(int a,int b,int c){
super(a,b);
this.c=c;
}
}
/*
* C.java
*
* Created on 2006年11月28日, 下午1:38
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/package mypack1;/**
*
* @author Administrator
*/
public class C {
/** Creates a new instance of C */
public C() {
}
public static void main(String []args){
A aa= new A();
System.out.println(aa.a+" "+aa.b);
B bb =new B();
System.out.println(bb.a + " "+bb.b +" "+ bb.c);
}
}
为什么这三个类放在同一个文件中不行,放在三个中就可以呢!!
int a;
int b;
/** Creates a new instance of A */
public A() {
this(1,9);
}
public A(int aa,int bb){
a=aa;
b=bb;
}
}
int c;
public B(){
this(1,2,1);
}
public B(int a,int b,int c){
super(a,b);
this.c=c;
}
}
/*
* C.java
*
* Created on 2006年11月28日, 下午1:38
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/package mypack1;/**
*
* @author Administrator
*/
public class C {
/** Creates a new instance of C */
public C() {
}
public static void main(String []args){
A aa= new A();
System.out.println(aa.a+" "+aa.b);
B bb =new B();
System.out.println(bb.a + " "+bb.b +" "+ bb.c);
}
}
为什么这三个类放在同一个文件中不行,放在三个中就可以呢!!
再说,你这两个类还是在不包中..
同一个java文件中只能有一个public class