title: Create an object and print it out but turns out printing the reference. How to solve this?
body: <p>Hi I was looking at another post on stackoverflow about objects, instances.</p>
  
  <p>I tried out some code.</p>
  
  <pre><code>public class Puppy{
  
     public Puppy(String name){
        // This constructor has one parameter, name.
       System.out.println(name);
     }
  
     public static void main(String []args){
        // Following statement would create an object myPuppy
        Puppy myPuppy = new Puppy("Tommy");
        Puppy myPuppy2 = new Puppy ("Sally");
        System.out.println(myPuppy);
     }
   }
  </code></pre>
  
  <p>The output is </p>
  
  <pre><code>Tommy
  Sally
  Puppy@58886ad0
  </code></pre>
  
  <p>Question: 
  when I try to print out the object myPuppy in the main method, it prints out its reference instead of the value? How should I solve this?</p>
  
  <p>Also, some mentioned that I did not actually store the puppy's name and I need to write a override toString method to print out the value instead of the reference.
  How should I accomplish the above?</p>
  
  <p>Thanks a lot!</p>