什么叫“使用if-else语句来将其分类为大于、小于、或等于紧随它而随机生成的值”呢,是说分为3个Collection么。public class SortRandomNumber {
public static void main(String[] args) {
Random r = new Random();
Map more = new TreeMap();
Map less = new TreeMap();
Map equal = new TreeMap();
Integer s = r.nextInt();
for(int i = 1; i < 25; i++) {
Integer temp = r.nextInt();
if(s > temp) {
more.put(i, s);
} else (s < temp) {
less.put(i, s);
} else {
equal.put(i, s);
}
s = temp;
}
}
}
2008年5月27日 00:56