简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM