Java
T
point
Home
Core Java
Servlet
JSP
Struts2
Mail API
Hibernate
Spring
Android
Design Pattern
Projects
Interview Q
View All Questions
Ask New Question
about string literal
By:
manish***
On:
Sat Jan 21 10:26:07 IST 2017
0
0
0
0
String s3="manish"+"kumar";
System.out.println(s3);
String s4=(new StringBuilder()).append("manish").append("kumar").toString();
System.out.println(s4);
System.out.println(s3==s4);//false
in string chapter you said that jvm converted like this. if jvm converted like this than how it is false. give me explanation.
0
You are comparing the hash code of an object i.e s3 and s4. To compare the contents of your string just use s3.equals(s4) method.
0
By:
[email protected]
On:
Sat Jan 21 11:02:58 IST 2017
0
0
0
0
Are You Satisfied :
0Yes
0No