This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alphanumeric values - range ?

 
kri shan
Ranch Hand
Posts: 1453
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
finding range between two alphanumeric values - like between HAI2TK and HAI9TD ? ( "HAI2TK", "HAI5TH","HAI9TD" )

implementing Comparator interface with compareTo() might supports. Any other optimized way ?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To implement this, you'll have to know what the logic behind the series is. For example, what is the next code after "HAI2TK"? When does one code come after or before another code in the series?

You didn't say anything about that logic, so we can't tell you exactly how to implement it in Java code.

Implementing a Comparator is indeed a way to express this in Java code.
 
kri shan
Ranch Hand
Posts: 1453
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HAI5TH comes after "HAI2TK",

"HAI9TD" comes after "HAI5TH"
 
Raymond Tong
Ranch Hand
Posts: 240
2
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kri shan wrote:HAI5TH comes after "HAI2TK",

"HAI9TD" comes after "HAI5TH"

You have provided "what" but not "how"
"HAI5TH" comes after "HAI2TK", but why ?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic