Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int i = 0; i < array.length; i++) {
int temp = array[i];
Integer count = map.get(temp);
map.put(temp, (count == null) ? 1 : count + 1);
}
有人可以帮我低估(count == null) ? 1 : count + 1
,以上吗?码。这是什么声明:(count == null)? 1:count + 1
这就是三元运算符。它基本上是说“if count == null,give 1. If if not,count count +1” – Emd4600
'?'被称为[ternary operator](https://en.wikipedia.org/wiki/%3F:#Java )。 – Tunaki
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html – JonK