I would like to discuss the problems I encountered with wrapper class Long
I used to use
1. Long is an object so when we use "==" it compares the object references.
2. Unboxing comes into play when we use comparison operators >,<
This is how I fixed the code.
I used to use
while ( null != startTimeIndex && prevTimeIndex.longValue() < startTimeIndex.longValue() && startTimeIndex < endTime) { }There are 2 problems with this approach
1. Long is an object so when we use "==" it compares the object references.
2. Unboxing comes into play when we use comparison operators >,<
This is how I fixed the code.
No comments:
Post a Comment