Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Programmer Certification (OCPJP)
about String & StringBuffer
Sundar Murthi
Ranch Hand
Posts: 209
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi..
consider the following code
Class Tst{ public static void main(String []arg){ String s1=new String("ABC"),s2=new String("ABC"); StringBuffer sb1=new StringBuffer(s1); StringBuffer sb1=new StringBuffer(s2); boolean b1=s1.hashCode()==s2.hashCode(); boolean b2=sb1.hashCode()==sb2.hashCode(); System.out.println(b1+","+b2); } }
what is the output?
The ans given is: true,false
The two
string
objects are different then how its comparsion gives true??
shrutisfsdf sharma
Greenhorn
Posts: 1
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
HashCode method in case of String is over ridden based on the value of the string,,whereas in case of stringbuffer its the same as of Object's.
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Question on Strings and String pool
Hashcode
stringBuffer hashcode
string buffer
StringBuffer??
More...