Post a Job  |   Ask a Question?   |   Already registered? login or register
Sukhendu Biswal
04/01/2017 01:14 AM

String Question--Mostly Asked

Assume that there are two string objects s1 and s2 in heap memory and you need to perform comparison of these two objects more often in your code. There is two solution. 1. s1.intern() == s2.intern() 2. s1.equals(s2) Which one will be faster comparison and how can possible? Plz explain.
Spam    4 Comments

04/01/2017 14:28:42
note:make sure u have to must and should override" .equals" and" hashcode "method otherwise its returns false u can test above example by commenting ".equls" and "hashCode" methods ***************************************************** Reason:if u not override .equals and hashcode mthods in our class then our class is by default implement from superclass as "Object.class" in Object class hashcode method as generationg hash value Randoumnly *********************************************************** still u want more info u can dig into java.lang packages u will get full info hope u can understand

04/01/2017 18:37:45
Dear Sasikanth, Thanks for nice explanation. But i wanna know if == is faster comparison, how? In String class we don't need to override equals() method,itz already overridden. As per our requirement we can override. In above question plz tell about interen() method.

05/01/2017 14:54:38

05/01/2017 17:03:36
hope u can understand and if u dont know what is SCP then tell me i will tell u what is scp,why sun peoples are designed it

Languages :