This string type bad comparison ah. .
------ Solution ---------------------------------------- ----
split split it, and then turn to an integer.
such as: 1.33.1
1 * 100 + 33 * 10 + 1 this year.
------ Solution ---------------------------------------- ----
split ('.'), and then one by one to compare the size
------ eference ---------------------- -----------------
Why is not there a versionCode
------ eference - --------------------------------------
you really creative ah
------ eference --------------------------------------- < br>
follow your example , it seems there will be the chance of error amount . .
such 1.33.1 = 431
and 2.13.1 = 331 smaller than before . . .
------ eference --------------------------------------- < br>
This idea can be used to determine whether the same version
------ eference -------------------------- -------------
version of this idea can be used to determine whether the agreement
judgment consistent with equals does not directly
------ eference - --------------------------------------
amount , I think so think , I wrote a way to go.
public static boolean checkupdate (String s1, String s2) {
String [] s1array = s1.split ("\ \.");
String [] s2array = s2.split ("\ \.");
int s1i = 0, s2i = 0;
if (s1array.length> = s2array.length) {
for (int i = 0; i
s2i = Integer.parseInt (s2array [i]);
if (s2i> s1i) {
return true;
}
}
return false;
} else {
for (int i = 0; i
s2i = Integer.parseInt (s2array [i]);
if (s2i
}
}
return true;
}
}
s2 big time returns true.
没有评论:
发表评论