title: Why does printing an Integer object print its int value?
body: <p>And can I create custom class objects and make them behave the same way ? e.g - </p>
  
  <p>If i have a class:</p>
  
  <pre><code>class MyCustomClass{
      int myDisplayValue;
      public MyCustomClass(int value){
          this.myDisplayValue = value;
      }
  }
  </code></pre>
  
  <p>and I use it as:</p>
  
  <pre><code>class TestClass{
      public static void main(String[] args){
          MyCustomClass testObj1 = new MyCustomClass(8);
          System.out.println(testObj1); // prints the class name with some random text
          Integer testObj2 = new Integer(8);
          System.out.println(testObj2); // prints the int value '8'
      }
  </code></pre>
  
  <p>Is there a way to make testObj1 print '8' as well? I realize that this might not be useful in any way and there are other ways of printing values more safely, I just want to know if this is possible.</p>