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
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Programmer Certification (OCPJP)
about equals
Sujittt Tripathyrr
Ranch Hand
Posts: 96
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
I have doubt in the below code :
1)
String
s1="Hi";
StringBuffer sb=new StringBuffer("Hi");
2)String s1="Hi";
String sb=new String("Hi");
The 1)returns False but the 2) returns False. Can you explain me why?
Pavel Kubal
Ranch Hand
Posts: 360
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
StringBuffer doesn't override equals.
Nilesh Patel
Ranch Hand
Posts: 91
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Check it..
https://coderanch.com/t/256729/java-programmer-SCJP/certification/Please-help-explain-output-following
Nilesh Patel
SCJP 1.5 - 87%
Kavita Kale
Ranch Hand
Posts: 34
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi sujitt
you have written that
The 1)returns False but the 2) returns False.
2nd point is not false please check that...
in your 1st point you have used stringbuffer that does not override equals() method so it returns false. but String allows you equals() so it returns true .
bye.
Sujittt Tripathyrr
Ranch Hand
Posts: 96
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Sorry Kavitha
The 2) is True you are right.
I got my answer.
Thanks
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
String and StringBuffer
String
about "=="and "equals" problem,I can't understand clearely?
StringBuffer and String doubt
equals() in Wrapper Classes
More...