这些号码存储在相同的整数变量。我怎么会去排序整数,以低到高?
11367 11358 11421 11530 11491 11218 11789
解决方案
有两种选择,真正做到:
使用标准的集合,被勒索 的解释 使用 Arrays.sort例如,
INT []整数= {11367,11358,11421,11530,11491,11218,11789};
Arrays.sort(整数);
的System.out.println(Arrays.asList(整型));
这当然假设你已经有你的整数作为数组。 如果您需要先解析这些,寻找 String.split 和Integer.parseInt.
These numbers are stored in the same integer variable. How would I go about sorting the integers in order lowest to highest?
11367 11358 11421 11530 11491 11218 11789
解决方案
There are two options, really:
Use standard collections, as explained by Shakedown Use Arrays.sortE.g.,
int[] ints = {11367, 11358, 11421, 11530, 11491, 11218, 11789};
Arrays.sort(ints);
System.out.println(Arrays.asList(ints));
That of course assumes that you already have your integers as an array. If you need to parse those first, look for String.split and Integer.parseInt.