Home TechnologyProgrammingJava Subscribe to RSS

What Are Advantages Java Reference Type Variables?

Answer Question

1 Answer - Sort by: Date | Rating

    Reference variables :

    * All non-primitive variables contain only references to objects on the heap.
    They never contain the object. C++ object variables may be either,
    but Java supports only object references.

    For Example :

    Book bookvar = new Book("Java");


    bookvar is not an object, it's a variable which contains a reference to an object.
    Objects don't have names, just types and locations in memory (and, of course,
    fields and methods).

    Create a new Book object in memory.
    Initialize it with the data sent as arguments to a constructor.
    When created, assign a reference to that object to the Book variable bookvar.
    "bookvar" is a reference or object type variable which may reference a Book object or
    an object of any subclass of Book.
    0 0

    Anshie 

    answered 9 months ago

    Can you explain more?

    I confuse with that explaination..^^
    i'm a new learner...
    Report
    Sanosuke

    Sanosuke

    commented 8 months ago

      Answer Question - Answers are editable for 5 min.

      If you do not Sign-in or Register your answers will

      be anonymous, your answers may also be

      checked before going online.

      0

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International