String 1.0.1.8 how to compare this type size Eg: less than 1.0.1.10 1.0.1.8 expectations
CodePudding user response:
Put the string through the split for network stations, and then according to the length of the array and the index comparison respectively, we have to do is Such as transformation of 1.0.1.8 array for a A length of 4 A [0]=1 A [1]=0 A [2]=1 A [3]=8 1.0.1.10 into array b Length for 4 b B [0]=1 B [1]=0 B [2]=1 B [3]=10
Then find two minimum length of the array in the array, according to the length of the array index Int iShortLength=a. ength<=b.l ength? A. ength: b.l ength; for (int i=0; I & lt; IShortLength; I++) { If (a [I] & gt; [I]) {b System. The out. Println (" first large number "); break; } else if (a [I] <[I]) {b System. The out. Println (" the second number "); break; }
If (I==iShortLength - 1) { System. The out. Println (" two as large number "); }