Skip to content
Advertisement

Java Object in list doesn’t get found

I have a problem. I have the following class:

JavaScript

Now I have a list containing 500 objects of these elements. Here are the first 4 shown:

JavaScript

In a variable I have stored the epoch of a specific datetime and with that I want to find the first valid cross, so I tried this:

JavaScript

But this code returns the value null When my searchEpoch is for example: 1514764800000. In the list I do see multiple objects that have a lower openTime than the searchEpoch. The result I want is the cross with the highest openTime, but it still has to be smaller than the searchEpoch.

Here is the error I get:

JavaScript

Why is my return value null?

Advertisement

Answer

This is caused due to the value the argument runDateTimeGMT0 is given and this:

JavaScript

Since this is working:

JavaScript

Output:

JavaScript

By the way, equals() is implemented without hashcode() – a recipe for problems.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement