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
Win a copy of
A Functional Approach to Java: Augmenting Object-Oriented Java Code with Functional Principles
this week in the
Functional programming
forum!
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
Liutauras Vilda
Ron McLeod
Jeanne Boyarsky
Paul Clapham
Sheriffs:
Junilu Lacar
Tim Cooke
Saloon Keepers:
Carey Brown
Stephan van Hulst
Tim Holloway
Peter Rooke
Himai Minh
Bartenders:
Piet Souris
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
about String & StringBuffer
Sundar Murthi
Ranch Hand
Posts: 209
posted 18 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 18 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.
I don't always make ads but when I do they're tiny
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
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...