i have a very a very basic question in mind .. i wanted to discuss ..
Difference Between these?
String s1= new String("java") ;
String s2="java" ;
Strings are immutable in Java and the String class maintains a pool of String objects that have been created. Using a String literal, as with s2 above, the String class will return the reference of the existing String, so all references to equivalent String literals will point to the same String object. When you create the String with the new String("java") constructor, you will actually get a new copy of the String "java", not the reference from the String pool. The following fragment of code will demonstrate this
String a = "java";
String b = new String("java");
String c = "java";
System.out.println("a==b : "+(a==b)); // false
System.out.println("a.equals(b) : "+(a.equals(b))); // true
System.out.println("a==c : "+(a==c)); //true
what for 2 different classes are there in garbage collection?