Ajay
Ajay

Reputation: 7438

Netbeans 6.5 debug issue

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

Upvotes: 0

Views: 110

Answers (1)

Zed
Zed

Reputation: 57678

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)) {
   ...
}

Upvotes: 2

Related Questions