java - after => Null Pointer -
i got code, , trying compare timestamp array:
timestamp oldesttstamp = timestamp[0]; boolean found = false; int temp = 0; (int j = 1; j<timestamp.length; j++){ if(oldesttstamp == null && timestamp[j] == null){} else if(oldesttstamp.after(timestamp[j])){ oldesttstamp = timestamp[j]; //retrieve oldest timestamp index in array found = true; temp = j; }
this how assign timestamp:
timestamp[index] = new timestamp(system.currenttimemillis());
your if
status written in unusual way, , checks if both timestamp
s null
. mean write
if (oldesttstamp != null && timestamp[j] != null && oldesttstamp.after(timestamp[j])) { ...
this way after()
method called if both oldesttstamp
, timestamp[j]
non-null.
java timestamp
No comments:
Post a Comment