public static void main(String[] args) {
Map<Integer, Integer> map = new HashMap<>()
Scanner scanner = new Scanner(System.in)
System.out.println("请输入0到50范围的数(输入-1结束)")
int num
// 输入 -1 则输入结束
while ((num = scanner.nextInt()) != -1) {
if (num < 0 || num > 50) {
System.out.println(num + " 不在0到50范围,请重新输入")
continue
}
Integer count = map.get(num)
map.put(num, count == null ? 1 : count + 1)
}
Set<Entry<Integer, Integer>> entrySet = map.entrySet()
for (Entry<Integer, Integer> entry : entrySet) {
System.out.println("数字 " + entry.getKey() + " 出现了 " + entry.getValue() + " 次")
}
}
}
1、查看你的JREDetect.class的路径,如果你是用网页调用的,要和网页放在同一个目录下。2、查看你封装JREDetect.class时是否调用了别的jar包,如果调用了,也要放在同一个目录下。
3、做一下自测,在你没封装JREDetect.class之前,先测试一下能不能使用。
<scjp考试指南>里面的题型就是了.差别只是真正考试的时候会告诉你多选题有几个正确答案..我也正在准备考试..第一章的自测题就做错了一半,被吓坏了..
加油吧!其实也不是很难,就是陷阱很多,要有扎实的基础.