Comparisons using Wrapper classes

I would like to discuss the problems I encountered with wrapper class Long

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:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days