public class b{ public static void main(String args[]){ StringBuffer sb1 = new StringBuffer("Amit"); StringBuffer sb2= new StringBuffer("Amit"); String ss1 = "Amit"; System.out.println(sb1==sb2); System.out.println(sb1.equals(sb2)); System.out.println(sb1.equals(ss1)); System.out.println("Poddar".substring(3)); } } What is the output?? and why??
public class b{ public static void main(String args[]){ StringBuffer sb1 = new StringBuffer("Amit"); StringBuffer sb2= new StringBuffer("Amit"); String ss1 = "Amit"; System.out.println(sb1==sb2); System.out.println(sb1.equals(sb2)); System.out.println(sb1.equals(ss1)); System.out.println("Poddar".substring(3)); } }
false The 2 StringBuffer objects do not point to the same object. false StringBuffer inherits the Object classes equals() method. So it is not doing the same thing that String equals() method does. false See above answer. dar Poddar - 0 based so 3 starts at the second d.
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?