I have the following class:
public class FilterValues {
private Boolean includeRecieved;
private Boolean includeUnrecieved;
//standard Getters and Setters for both Boolean fields...
}
Elsewhere in the code, in another class, the two fields are being compared to see if both are true or both are false using:
if (filterValue.getIncludeRecieved() == filterValue.getIncludeUnrecieved())
First off, allow me to explain that I realize that the proper method would be to use the .equals() method for this comparison.
My question is that, when given the scenario that both fields are set to true, the above comparison is returning 'true' and entering the if statement when working on my local. However, when posted to our server, the same scenario returns 'false' and will skip the if statement. The issue was fixed by changing the code to:
if (filterValue.getIncludeRecieved().equals(filterValue.getIncludeUnrecieved()))
However I cannot find any explanation for why the difference in behavior occurs in the different environments. I have looked into the documentation and could not find anything that would cause this. I need to understand the why so that I can ensure that this bug does not occur elsewhere, since QA is unable to detect it on their local machines either.
Could anyone please explain what is causing the difference in Java's behavior between the two environments?