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
Last week, we had the author of
TDD for a Shopping Website LiveProject
. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See
for the agenda and registration link
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
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
Programmer Certification (OCPJP)
String doubt
Ashok Pradhan
Ranch Hand
Posts: 180
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
in JLS It states that for any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true.
public class Test1 { public static void main(String[] args) { String s="test"; String s1 = new String("test"); System.out.println(s1.intern()==s); //line 1 System.out.println(s.intern()==s1); //line 2 } }
OUTPUT
true
false
i am confusing why line 2 returns false.please explain it and thanks.
sridhar row
Ranch Hand
Posts: 162
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What do you want it to return? hint: You are using ==.
Ashok Pradhan
Ranch Hand
Posts: 180
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks I get it.
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Deadlocks in Threads?
Object Create
String.intern() Method
this will make you think
StringBuffer and String doubt
More...