avoid NullPointerException at the first cycle
Posted
by
user1508419
on Stack Overflow
See other posts from Stack Overflow
or by user1508419
Published on 2012-07-08T08:57:47Z
Indexed on
2012/07/08
9:15 UTC
Read the original article
Hit count: 164
java
|nullpointerexception
I have this piece of code:
EventSnapshot snapshotEvent = new EventSnapshot();
EventSnapshot currentEvent = new EventSnapshot();
do
{
...
currentEvent.setContent(in_stats);
...
if(!snapshotEvent.equals(currentEvent))
snapshotEvent.setContent(in_stats);
}
while(true);
At the first cycle I get a NullPointerException
because obviously the object snapshotEvent is empty. At the second cycle this doesn't happen.how can avoid this problem?
© Stack Overflow or respective owner