

Once we create test object we can't perform any change in the existing object if we are trying to perform any change and if there is a change in the content then with those changes a new object will be created and if there is no change in the content then existing object will be reused.įinal applicable for variables but not for objects where as immubility applicable for objects but not for variables. This behavior is nothing but immutability If there is no change in the content then existing object will be reused. Once we creates an object we can't perform any changes in that object if we are trying to perform any change and if there is a change in the content then with those changes a new object will be created. Garbage collector is not allowed to access SCP area hence even though object doesn't contain reference variable it is not illegible for GC if it is present in SCP area.Īll SCP objects will be destroyed automatically at the time of JVM shutdown. But this rule is applicable only for SCP but not for the HeapĢ. If object not already available in SCP then only a new object will be created. If object already present then existing object will be reused. Object creation in SCP is optional first it will check, is there any object already present in SCP with required content. In this case 2 objects will be in this case only one object will be created inĬreated 1 in the heap area SCP and s is always pointing to that objectġ. String s = new String("Durga") String s = "Durga" equals() method returns false even though equals() method comparison(address comparision). equals() method got executed which is ment for referenceĬontent is same then. Is overridden for content comparison, for content comparison hence if objects classĮven though objects are different if. Sopln(s1.equals(s2)) //true sopln(sb1 = sb2) //false Sopln(s1 = s2) //false sopln(sb1 = sb2) //false String s2 = new String("Durga") StringBuffer sb2 = new StringBuffer("Durga") String s1 = new String("Durga") StringBuffer sb1 = new StringBuffer("Durga") is nothing but mutability of String buffer object.Ĭhange with those changes a new sb->Durga softwareĭurgaSoftware // but nothing to pointing this object We can't perform any changes in change in the existing object this changable behavior

Once we create a String object once we create StringBuffer object we can perform any Sopln(s) //Durga sopln(sb) // Durga Software S.concad("software") sb.append(" software") String s = new String("Durga ") StringBuffer sb = new StringBuffer("Durga")
