| 
 | 
 
 
 楼主 |
发表于 2020-7-25 15:16:33
|
显示全部楼层
 
 
 
public class Student { 
String name; 
int age; 
String degree; 
} 
 
 public class Graduate extends Student{ 
                String direction; 
                public void show(){ 
                        System.out.println(name+age+degree+direction); 
                } 
                Graduate(String name,int age,String degree,String direction){ 
                        this.name=name; 
                        this.age=age; 
                        this.degree=degree; 
                        this.direction=direction; 
                } 
        } 
 
public class Undergraduate extends Student{ 
        String        specialty; 
        public void show(){ 
                System.out.println(name+age+degree+specialty); 
        } 
        Undergraduate(String name,int age,String degree,String specialty){ 
                this.name=name; 
                this.age=age; 
                this.degree=degree; 
                this.specialty=specialty; 
        } 
} 
 
java中只能定义一个public class类,要怎么改 
 |   
 
 
 
 |