same reference  for multiple objects..?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/10615151/hash-code-for-string-objects">hash code for string objects</a>  </p>
</blockquote>



<p>Hi I am new to java programming,i want to create to multiple number of obj of Myclass, for that written the code Below.why does it generating same objects</p>

<pre><code>class Myclass {

        private static Myclass single;
        private Myclass() {

        }
        public static synchronized Myclass obj() {
            if (single == null) {
                single = new Myclass();
            }
            return single;
        }
    }
    public class Demo {
        public static void main(String args[]) {
            Myclass obj = Myclass.obj();
            System.out.println("one  "+obj);
            Myclass obj1 = Myclass.obj();
            System.out.println("two  "+obj1);
        }
    }
</code></pre>
