- class SuperEx {
- String r;
- String s;
- public SuperEx(String a, String b) {
- r = a;
- s = b;
- }
- public void aMethod(){
- System.out.println("r:"+r);
- }
- }
- class SubEx extends SuperEx {
- public SubEx(String a, String b){
- super(a, b);
- }
- public static void main(String[] args){
- SuperEx a = new SuperEx("Hi", "Tom");
- SuperEx b = new SubEx("Hi", "Bart");
- a.aMethod();
- b.aMethod();
- }
- public void aMethod(){
- System.out.println("r:"+r+"s:"+s);
- }
- }
复制代码
|
|