码迷,mamicode.com
首页 > 其他好文 > 详细

1//继承和重写方法。。。。

时间:2016-01-20 17:21:23      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

 1 package com.mingrisoft;
 2 public class Employee {
 3 
 4     
 5     private String name;
 6     private double gongzi;
 7     
 8     public String getName() {
 9         return name;
10     }
11 
12     public void setName(String name) {
13         this.name = name;
14     }
15 
16     public double getGongzi() {
17         return gongzi;
18     }
19 
20     public void setGongzi(double gongzi) {
21         this.gongzi = gongzi;
22     }
23 }
24 
25 public class Manager extends Employee {
26 
27     private String Name;
28 //    
29 //    private double GongZi;
30     
31     public double JiangJin=3000.0;
32 
33     public double getJiangJin() {
34         
35         return JiangJin;
36     }
37 
38     public void setJiangJin(double jiangJin) {
39         JiangJin = jiangJin;
40     }
41 
42 //    public double getGongZi() {
43 //        return GongZi;
44 //    }
45 //
46 //    public void setGongZi(double gongZi) {
47 //        GongZi = gongZi;
48 //    }
49     public void setName(String name){
50         
51         Name=name;
52     }
53     public void setName(){
54         
55         
56     }
57     
58 }
59 
60 public class Test {
61 
62     public static void main(String[] args) {
63         
64         Manager manager = new Manager();
65         
66         Employee employee=new Employee();
67         
68         manager.setName("123");
69         
70         employee.setName("456");
71         
72         System.out.println(manager.getJiangJin());
73         
74         System.out.println(employee.getName());
75         
76         System.out.println(manager.getName());
77         
78         
79         
80     }
81 
82 }

3000.0
456
null

1//继承和重写方法。。。。

标签:

原文地址:http://www.cnblogs.com/as1234as/p/5145681.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!