Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Find the lowest string using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Find the lowest string using Java" Watch "Find the lowest string using Java" New topic
Author

Find the lowest string using Java

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202

I have two strings "XYO2" and "M7I9". I have a requirement to pick lowest of these string. Actually, the result of this selection should be similar to NLSSORT (AMERICAN Lang) functionality of ORACLE.

Should I calculate and sum up the ASCII value of every character in those Strings and then come to the conclusion which is the lowest or is there any other way in java. please suggest.

Thanks in Advance
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14118
    
  17

Have a look at the API documentation of class java.lang.String and check if there are methods there that you could use to compare the strings.

You don't have to do anything complicated like calculate and sum up the ASCII value of the characters. (Summing up the characters? That wouldn't even work to sort the strings).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Find the lowest string using Java