Got different result from (Eclipse VS NetBean)
Quote:
public class calTest {
public int i = 1;
private int j = 1;
public static void main(String[] args) {
}
public void runCal() {
System.out.println("before i = " + i);
System.out.println("before j = " + j);
System.out.println("i = " + i);
System.out.println("j = " + j);
}
}
Eclipse result:
3
3
NetBean result:
3
4
Command line result:
3
4
Why is it different?
Which result should be the correct one?
Can anyone explain it in detail?
Thank you very much in advance.
Re: Got different result from (Eclipse VS NetBean)
Tried your code and got the same result for Eclipse, NetBeans and command line:
before i = 1
before j = 1
i = 3
j = 3
Are you positive the code is the same in Eclipse and NetBeans?
2 Attachment(s)
Re: Got different result from (Eclipse VS NetBean)
Thank you for your reply:
Yup, exactly the same code.
To confirm this, I purposely created the same class again and copy/paste the code from here.
Both Eclipse and NetBean again gave the same result as I got previously.
Eclipse: 3, 3 and NetBean: 3, 4 (see below pics).
Eclipse version 3.7.2 & NetBean version 7.1.1, what version are your using?
Re: Got different result from (Eclipse VS NetBean)
Indeed. I see the same thing with
NetBeans IDE 7.1.1 (Build 201203012225)
1.7.0_03; Java HotSpot(TM) Client VM 22.1-b02
Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
vs
Eclipse IDE for Java Developers
Version: Indigo Service Release 1
Build id: 20110916-0149
-----
According to Google this queston has come up (same code) in a few places in the last little while. What is said in this OTN thread by way of explanation seems good to me. Eclipse FTW!
Re: Got different result from (Eclipse VS NetBean)
Make the answer the same. 3,3 or 4,4 !!!!!!
3,4 cause confusion for the DEFINITION of public and private.
"Sorry Sir, public vs. private, 1M is deducted from your saving account."
"Good news Sir, the new compiler get you back the 1M that you have lost 1 year ago."
That's very stupid !