This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Java in General and the fly likes Alphanumeric values - range ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Alphanumeric values - range ?" Watch "Alphanumeric values - range ?" New topic

Alphanumeric values - range ?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1396
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

Joined: Aug 16, 2005
Posts: 14917

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1396
HAI5TH comes after "HAI2TK",

"HAI9TD" comes after "HAI5TH"
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 235

kri shan wrote:HAI5TH comes after "HAI2TK",

"HAI9TD" comes after "HAI5TH"

You have provided "what" but not "how"
"HAI5TH" comes after "HAI2TK", but why ?
I agree. Here's the link:
subject: Alphanumeric values - range ?
It's not a secret anymore!