title: This in Java - Exception in thread "main" java.lang.StackOverflowError
body: <p>Why am I getting a stackoverflow error ?</p>
  
  <p><strong>My class -</strong> </p>
  
  <pre><code>public class Tester {
  
  int id;
  
   Tester(int id){
    this.id = id;
   }
  
   public String toString(){
  
    String rep = "Hex: " + this + ", Id: " + this.id;
    return rep;
   }
  
  }
  </code></pre>
  
  <p><strong>The main method -</strong> </p>
  
  <pre><code>class Driver{
  
      public static void main(String [] args){
  
          Tester t = new Tester(123);
          System.out.println(t);
  
      }
  
  }
  </code></pre>
  
  <p><strong>Error -</strong> </p>
  
  <pre><code>Exception in thread "main" java.lang.StackOverflowError
      at java.lang.String.length(Unknown Source)
      at java.lang.AbstractStringBuilder.append(Unknown Source)
      at java.lang.StringBuilder.append(Unknown Source)
      at java.lang.StringBuilder.&lt;init&gt;(Unknown Source)
      at com.examscam.model.Tester.toString(Tester.java:13)
      at java.lang.String.valueOf(Unknown Source)
      at java.lang.StringBuilder.append(Unknown Source)
  
  ---------REPEAT !!!
  </code></pre>