File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Find the lowest string using Java" Watch "Find the lowest string using Java" New topic

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: 13872

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
I agree. Here's the link:
subject: Find the lowest string using Java
Similar Threads
method construction trouble
career advice
what is the trick
saprating strings with commas one by one
how many bytes in char