Efficient way to compare version strings in Java

Viewed 65737

Possible Duplicate:
How do you compare two version Strings in Java?

I've 2 strings which contains version information as shown below:

str1 = "1.2"
str2 = "1.1.2"

Now, can any one tell me the efficient way to compare these versions inside strings in Java & return 0 , if they're equal, -1, if str1 < str2 & 1 if str1>str2.

10 Answers
Related