Results 1 to 5 of 5
  1. #1
    anjibman is offline Member
    Join Date
    Dec 2010
    Posts
    33
    Rep Power
    0

    Default Meaning of XXX@yyyyy

    Hi All,

    What is the meaning of the Customer@xxxxx?

    Java Code:
    public class PassByValueTest {
    
        public static void main(String[] args) {
            Customer customer = new Customer("Don");
            System.out.println(customer); //prints “Customer@2aa05bc3”
            testValue(customer); //value “2aa05bc3”is passed
        }
    
        public static void testValue(Customer cust) {
            System.out.println(cust); //prints “Customer@2aa05bc3”
            cust = new Customer("Peggy");
            System.out.println(cust);"//prints "Customer@5e87512"
        }    
    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default Re: Meaning of XXX@yyyyy

    You're trying to print a Customer object, so the PrintStream object calls the toString() method on the Customer object. You didn't define that method so the inherited method from the Object class is called. Read the API documentation for that method and you'll understand why your Customer object prints like that.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    anjibman is offline Member
    Join Date
    Dec 2010
    Posts
    33
    Rep Power
    0

    Default Re: Meaning of XXX@yyyyy

    So just want to confirm that it is hash code of the object not a address of the object .. correct?
    is there anyway we can print the address of the object(Customer "Don") and object reference("Cusotmer")?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default Re: Meaning of XXX@yyyyy

    Correct, the part after the '@' is the hash code of the object; for the real address of an object you need a bit of native code; but why should you need the address of an object?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    anjibman is offline Member
    Join Date
    Dec 2010
    Posts
    33
    Rep Power
    0

    Default Re: Meaning of XXX@yyyyy

    As for my example to make clear what value is being passed in line #6.

Similar Threads

  1. Error meaning
    By Johanis in forum New To Java
    Replies: 2
    Last Post: 10-16-2012, 10:11 AM
  2. The meaning of replaceAll
    By herolua in forum New To Java
    Replies: 4
    Last Post: 10-07-2011, 05:18 AM
  3. Phrase Meaning
    By griddle in forum New To Java
    Replies: 1
    Last Post: 04-25-2011, 06:45 PM
  4. for loop meaning
    By ahmakki in forum New To Java
    Replies: 3
    Last Post: 04-12-2010, 01:06 AM
  5. Exception:Meaning
    By tiger100plus in forum New To Java
    Replies: 2
    Last Post: 11-27-2008, 07:45 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
  •