Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Find the lowest string using Java

 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 15437
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic