Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java CompareTo Method

807603Feb 13 2006 — edited Nov 27 2007
does anyone know how the string compareTo method actually works? I am trying to use a binary search to find a word in an arraylist with a specific prefix.

i know that the compareTo method returns a 1 0 or -1 based on what the result of the comparison is but im interested in teh actual way that the comparison takes place.

Since i will be comparing a prefix to a complete word, i would like to know if this would cause any problems due to the difference in string lengths.

Do you guys have any other idea on how i can use a very fast searching method to search a sorted arraylist of words to see if any word with a specific prefix exists?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 25 2007
Added on Feb 13 2006
6 comments
646 views