星空网 > 软件开发 > Java

is A和has A的区别

is Ahas A

Red is A Color:                     

                        class Red extends Color{}

                        class Blue extends Color{}

                        class Yellow exrends Color{}

She has A friend:

                           class She{

                              private Person friend;

                           }

继承关系

(分为:

          接口继承——扩展父类类型或功能

                                  略

          实现继承——实现公共代码的重用

 

 1 class Red extends Color{ 2  3       public void sayHello(){ 4  5          System.out.print("大家好,"); 6  7               } 8  9            }10 11 class Red extends Color{12 13         @OverWrite14 15         public void sayHello(){16 17          super.sayHello();18 19          System.out.println("我叫red!");20 21            }22 23          }24 25 26 class Blue extends Color{27 29          @OverWrite31 32         public void sayHello(){34 35            super.sayHello(); 37 38            System.out.println("我叫blue!"); 40 41             }42 43 44          }

 

 

 

                              

 

 

从属关系

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 




原标题:is A和has A的区别

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

英驰 imc :https://www.goluckyvip.com/tag/47881.html
英创国际咨询:https://www.goluckyvip.com/tag/47882.html
英达沃体育:https://www.goluckyvip.com/tag/47884.html
英国 fba 头程:https://www.goluckyvip.com/tag/47885.html
英国fba 头程:https://www.goluckyvip.com/tag/47886.html
英国fba仓:https://www.goluckyvip.com/tag/47887.html
川藏线自驾游要怎么走才比较划算呢?:https://www.vstour.cn/a/411240.html
去日本入住酒店,东西随意用却有一个特殊“要:https://www.vstour.cn/a/411241.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流