Question

I am debugging the following lines of code


    if (var.getvar2() != var3) {
           var4.add(var);
    } else {
           isNeeded= true;
           if (incomingPublishedDate.compare(modifiedDate) < 0) {
               importNeeded = true;
           } else {
               var4.add(var);
           }
   }

Here var.getvar2() and var3 are of type Long. While debugging, when the condition goes like

10000 != 10000

the if should evaluate to false. But from the first if, the next Step Over goes to

var4.add(var);

and the next Step Over goes to var4.add(var);

Is this a Netbeans bug? Or is it with the Long comparision.

I am using Netbeans IDE 6.5

Was it helpful?

Solution

You cannot compare objects by value. That comparison would only be true if the two references compared refer to the same object. Instead use:

if (! var.getvar2().equals(var3)) {
   ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top