Results 1 to 2 of 2
  1. #1
    N00Bie is offline Senior Member
    Join Date
    Feb 2011
    Rep Power

    Default Initialize Vs extends

    I'm a bit confused...

    If you can simply add a "extends X" keyword on top to get access to all of the other classes variables and methods

    why do the
    TheClass x = new TheClass();


  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Rep Power


    extends defines identity, also known as an is-A relationship.
    You do the other thing (also known as composition) when you just want the behaviour without changing the type of the guy providing the behaviour.

    Generally, it is easier to acquire/change behaviour than it is to change identity.

Similar Threads

  1. Advanced extends and implements
    By V1C3M4N in forum Advanced Java
    Replies: 15
    Last Post: 11-17-2010, 01:28 PM
  2. Class that extends JFrame help
    By javaman1 in forum New To Java
    Replies: 5
    Last Post: 11-10-2010, 02:29 AM
  3. servlet extends ..web server?
    By waqar100 in forum Java Servlet
    Replies: 5
    Last Post: 06-08-2010, 05:18 AM
  4. extends question
    By mac in forum New To Java
    Replies: 8
    Last Post: 04-03-2010, 02:29 AM
  5. My icon extends my JButton
    By hitmen in forum AWT / Swing
    Replies: 5
    Last Post: 03-06-2009, 07:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts