Results 1 to 10 of 10
- 05-18-2011, 05:46 PM #1
Member
- Join Date
- May 2011
- Posts
- 3
- Rep Power
- 0
- 05-18-2011, 05:54 PM #2
Why don't you use System.out.println(z); and find out?
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 05-18-2011, 06:12 PM #3
Member
- Join Date
- May 2011
- Posts
- 3
- Rep Power
- 0
I was hoping that someone here could tell me the (correct) answer... :)
- 05-18-2011, 06:21 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,373
- Blog Entries
- 7
- Rep Power
- 17
It all depends on what the hasCode() method in the String class returns; here it is:
b.t.w. you can find this in the src.zip file stored in your JDK directory.Java Code:public int hashCode() { int h = hash; if (h == 0) { int off = offset; char val[] = value; int len = count; for (int i = 0; i < len; i++) { h = 31*h + val[off++]; } hash = h; } return h; }
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 05-18-2011, 06:28 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
You think we keep the value of something like:
"WWI".hashCode()
in our heads?
Well, maybe Jos does, but he's strange.
- 05-18-2011, 06:32 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,373
- Blog Entries
- 7
- Rep Power
- 17
- 05-18-2011, 06:34 PM #7
You were asking for a handout, I told you how to figure it out.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 05-18-2011, 06:36 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
- 05-18-2011, 06:53 PM #9
Member
- Join Date
- May 2011
- Posts
- 3
- Rep Power
- 0
- 05-18-2011, 08:05 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,373
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
programming career advice question
By silverglade in forum Jobs DiscussionReplies: 2Last Post: 05-23-2011, 07:39 AM -
simple game programming help
By b.m in forum New To JavaReplies: 0Last Post: 11-25-2010, 05:16 PM -
Fairly Simple (I think) programming project
By Glyph in forum Jobs OfferedReplies: 0Last Post: 10-22-2010, 12:16 AM -
Simple Programming problem loop in array
By katon in forum New To JavaReplies: 1Last Post: 12-20-2009, 03:14 PM -
Programming Socket Question
By paul in forum NetworkingReplies: 1Last Post: 07-30-2007, 07:26 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks