li xiaoming
2010-04-07 03:21:00 UTC
public class Test {
public static void main(String[] args) {
ConcurrentHashMap<Long, Long> ls = new ConcurrentHashMap<Long, Long>();
for (long i=0; i<10; i++) {
ls.put(i, i);
}
for (long i=0; i<20; i++) {
if (ls.containsKey(i)) {
long num = ls.get(i);
System.out.println(i + "--->" + num);
}
}
}
}
Bug: Possible null pointer dereference due to return value of called method
Pattern id: NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE, type: NP, category: STYLE
The return value from a method is dereferenced without a null check, and the return value of that method is one that should generally be checked for null. This may lead to a NullPointerException when the code is executed.
why the code is taged by red throw NullPointerException?
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969
public static void main(String[] args) {
ConcurrentHashMap<Long, Long> ls = new ConcurrentHashMap<Long, Long>();
for (long i=0; i<10; i++) {
ls.put(i, i);
}
for (long i=0; i<20; i++) {
if (ls.containsKey(i)) {
long num = ls.get(i);
System.out.println(i + "--->" + num);
}
}
}
}
Bug: Possible null pointer dereference due to return value of called method
Pattern id: NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE, type: NP, category: STYLE
The return value from a method is dereferenced without a null check, and the return value of that method is one that should generally be checked for null. This may lead to a NullPointerException when the code is executed.
why the code is taged by red throw NullPointerException?
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969