Printing a java object value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gjain12
    New Member
    • Jun 2008
    • 19

    Printing a java object value

    Hi all,

    I have created a java object that contains some xml tags. When I print it using obj.toString(), it displays some hashed value something like objecttype@1234 5. But I want to display the exact value that it contains. Does anybody know how to do this?

    Thanks
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Override the toString method in your class to display what you want.
    The default behavior of toString inherited from mother Object simply outputs the class name @ the hexadecimal value of the hash code.

    Comment

    • gjain12
      New Member
      • Jun 2008
      • 19

      #3
      Printing a java object value

      Actually, the thing is that using APIs I have created this object and I am not sure whether it has been created correct or not. Thats why I wanted to print it.

      This should create some xml. Do you have any idea how can I know whether the format of my xml is correct or not?

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Since you are not getting null then it means that the object was certainly created.
        How to find out what's in it e.t.c depends on the methods available for that object. What class type is it? Do you have the API docs for that class?

        Comment

        • gjain12
          New Member
          • Jun 2008
          • 19

          #5
          Actually this makes use of custom APIs that has been developed by third party and I don't have the API docs but I know that whatever attribute I have set using set methods have corresponding get methods also.

          Actually my concern is to see the complete XML with tags creted by those methods.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Perhaps I'm not getting what you are asking but why not just call the methods that return the XML (if there are any) to see what the XML is.
            P.S Using any third party package that is not well documented and doesn't have API docs is a complete waste of time. How would you know what a method does when you call it?

            Comment

            • gjain12
              New Member
              • Jun 2008
              • 19

              #7
              ok..thanks I think I have to get back to them and ask for docs.

              Comment

              Working...