Is there a standard idiom for comparing version numbers? I can't just use a straight String compareTo because I don't know yet what the maximum number of point releases there will be. I need to compare the versions and have the following hold true:
1.0 < 1.1
1.0.1 < 1.1
1.9 < 1.10
My java Solution
This code try to resolve this type of comparison versions.
Wondering why everybody assumes that the versions is only made up of integers - in my case it was not.
Why reinventing the wheel (assuming the version follows the Semver standard)
First install https://github.com/vdurmont/semver4j via Maven
Then use this library
Example:
Output:
I liked the idea from @Peter Lawrey, And i extended it to further limits :
Hope it helps someone. It passed all test cases in interviewbit and leetcode (need to uncomment two lines in compareVersion function).
Easily tested !