- public class Yuangong
- {
- String name;
- String id;
- double salary;
- public void setname (String name)
- {
- this.name=name;
- }
- public String getname()
- {
- return name;
- }
- public void setnum (String id)
- {
- this.id = id;
- }
- public String getnum()
- {
- return id;
- }
-
- void setnum (double salary)
- {
- this.salary = salary;
- }
- public double getsalary()
- {
- return salary;
- }
- Yuangong(String name, String id , double salary)
- {
- this.name = name;
- this.id = id;
- this.salary = salary;
- }
- public void print()
- {
- System.out.println(name+".."+id+".."+salary);
- }
-
- }
- public class Jingli extends Yuangong
- {
- int reward;
- Jingli(String name, String id , double salary , int reward)
- {
- super(name,id,salary);
- this.reward = reward;
- }
- public void print()
- {
- System.out.println(name+".."+id+".."+salary+".."+reward);
- }
- }
- public class AbstractDemo
- {
- public static void main(String[] args)
- {
- Jingli a = new Jingli ("经理","1000",5000,200);
- Yuangong b = new Yuangong ("员工1","10001",3500);
- a.print();
- b.print();
- }
- }
复制代码
提示我说是什么java 类是公共的,应在名为.java 的文件中声明 这是怎么回事 |