So, i have this List of Folders which represent the Versions of a Program and i want to get the latest (there are some junk files next to the Folders!):
0.0.0.256
0.0.1.1
0.0.1.2
0.0.1.5
0.0.1.11
0.0.1.68
0.0.2.1
and so on.
If i want to get only the latest Version Folder here, how could i accomplish that?
Currently, i know that the version wont rise higher than 0.0.1.x for now, (the above is only an example) so i could use
for(String name:names)
{
if (name.indexOf("0.0.1")==0)
{
ret = name;
}
}
System.out.println("Current Installed Version Folder: "+ret);
but that wont last forever. How could i write some code, that will always give me the highest representive Version number? I can think of a way how to do it right now (checking the 0th char, then the 2nd, 4th and so on) but i think there is a smarter way. Any quick ideas?