`
Jerryhome
  • 浏览: 2531 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Java中is-a和has-a的区别

 
阅读更多

1.“is-a”是继承的关系,比如人是动物,人和动物是继承的关系;
2.“has-a”是聚合的关系,比如人有眼睛,人和眼睛是聚合的关系;
3.如果一个类继承自另一个类,那么它们是“is-a”的关系,如果一个类的成员中引用了另一个类,那么它们是“has-a”的关系。

分享到:
评论

相关推荐

    Java: High-Performance Apps with Java 9

    Apart from this, he is also a prolific business writer who has authored two international award-winning books, Unbarred Innovation: A Pathway to Greatest Discoveries and Evolve Like a Butterfly: A ...

    初级java笔试题-is-has-get:一个用于javascript的微型实用程序库

    get从元素和对象中挖掘东西。 ishasget是依赖和回调免费。 例子 is可以回答你,如果事情是,即一个字符串是否是有效的JSON: is.json( '{ "firstName": "John", "lastName": "Smith" }' ); // => true has启用了...

    JAVA正则表达式--Pattern和Matcher

    "Kevin has seen 《LEON》 several times, because it is a good film.\n" + "凯文已经看过《这个杀手不太冷》几次了,因为它是一部\n" + "好电影。/名词: 凯文。"); for (int i = 0; i ; i++) { System.out....

    java基本概念--java程序开发的基本概念

    6. **类之间的关系**:use-a(依赖)、has-a(聚合)、is-a(继承),继承体现了“子类是父类”的关系。 7. **构造器**:用于创建和初始化对象的特殊方法,与类名相同,无返回值。 8. **方法重载**:同一类中方...

    JAVA笔试题--Java选择题100道

    **答案解析**: 选项A中,“default”不是Java中的访问控制修饰符;选项B中,方法声明缺少大括号;选项C中,抽象变量声明在Java中是不允许的。选项D中的声明是合法的,它声明了一个抽象的final方法,这是合理的,因为...

    Java语言规范

    THE Java™ programming language is a general-purpose, concurrent, classbased, object-oriented language. It is designed to be simple enough that many programmers can achieve fluency in the language. ...

    java-ee-8-microservices.rar

    Cloud-based applications have been increasingly in demand, and this has caused a shift from monolithic to microservice applications. With the help of Java EE 8 Microservices, you’ll get to grips with...

    javacv-platform-1.3.3-src

    // CanvasFrame is a JFrame containing a Canvas component, which is hardware accelerated. // It can also switch into full-screen mode when called with a screenNumber. // We should also specify the ...

    test-driven-java-development-2nd2018

    goal of becoming a Java developer with a TDD black belt. In order to know where we're going, we'll have to discuss and find answers to some questions that will define our voyage. Chapter 2, Tools, ...

    A Little Java, A Few Patterns

    Java is a new object-oriented programming language that was developed by Sun Microsystems for programming the Internet and intelligent appliances. In a very short time it has become one of the most ...

    Java Programming 24-Hour Trainer(Wrox,2ed,2015)

    Java Programming 24-Hour Trainer, 2nd Edition is your complete beginner's guide to the Java programming language, with easy-to-follow lessons and supplemental exercises that help you get up and ...

    JAdhoc-JAdhoc is a Java-based implementation of the AODV protocol

    JAdhoc is a Java-based implementation of the AODV protocol. It complies with RFC3561, and works on IPv4. It is implemented using the Java libraries for networking, graphical user interfaces, multi-...

    Pro-Java-Clustering-and-Scalability.pdf

    My name is Jorge Acetozi, and I’m a Brazilian software engineer who has worked for many years as a Java developer. During my career, I have been interested in subjects such as these: • Linux • ...

    java矩阵包Jampack: A Java Matrix Package

    ampack (JAva Matrix PACKage) is a collection of cooperating classes designed to perform matrix computations in Java applications. Jampack was developed by the author at NIST and the University of ...

    java jwt jar包

    总的来说,`jjwt-0.7.0.jar`为Java开发者提供了一个强大的工具,帮助他们在应用程序中轻松地实现JWT相关的功能,包括身份验证、授权以及安全的数据传递。这个库支持多种签名算法,如HS256、HS384、HS512以及RSA和...

    java-class-api

    Controls whether or not the event is sent back down to the peer once the source has processed it - false means it's sent to the peer; true means it's not. Semantic events always have a 'true' value ...

    Microservices for Java EE Architects-DVT Press(2016).azw3

    It is an important architecture with a variety of uses that Java architects should understand and be able to use. This book details microservices architecture and is an addendum to the Java EE ...

Global site tag (gtag.js) - Google Analytics