Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Java only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
Java
Doubt related two string
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
hirak1984
Contributor
Join Date:
Jan 2007
Posts:
316
#1
Doubt related two string
Jul 19 '07, 08:39 AM
Can there be any condition between two strings( say "a" and "b" ) where
a.equals(b) returns true
but
b.equals(a) returns false ?
emekadavid
New Member
Join Date:
Mar 2007
Posts:
46
#2
Jul 19 '07, 09:02 AM
that's a set of strings. nice to do that in java
Comment
Post
Cancel
prometheuzz
Recognized Expert
New Member
Join Date:
Apr 2007
Posts:
197
#3
Jul 19 '07, 09:57 AM
Originally posted by
hirak1984
Can there be any condition between two strings( say "a" and "b" ) where
a.equals(b) returns true
but
b.equals(a) returns false ?
No, it is a symetric relation: if a equals b, b equals a.
Comment
Post
Cancel
emekadavid
New Member
Join Date:
Mar 2007
Posts:
46
#4
Jul 19 '07, 10:48 AM
thanks for your correction prometheuz. answer is no. String comparison follows character mappings. I saw containment when i threw that answer
Comment
Post
Cancel
hirak1984
Contributor
Join Date:
Jan 2007
Posts:
316
#5
Jul 19 '07, 12:07 PM
well thanks for the answer.. to both of you
Originally posted by
emekadavid
thanks for your correction prometheuz. answer is no. String comparison follows character mappings. I saw containment when i threw that answer
Comment
Post
Cancel
JosAH
Recognized Expert
MVP
Join Date:
Mar 2007
Posts:
11453
#6
Jul 19 '07, 01:16 PM
I wish that Gosling and his mates had thought a bit more and put in a less()
method in the Object class too instead of just an equals() method. The default
implementation could have been:
[code=java]
bublic boolean less(Object that) return this.hashCode() < that.hashCode() ; }
[/code]
We wouldn't have needed that silly Comparable interface then.
kind regards,
Jos
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment