I have this code in one file:
public class genIntro { public static void main(String [] args){ genTest g = new genTest(); g.add( 10 ); System.out.println( g.get() == new Integer(10) ? true:false ); Integer in = (Integer) g.get(); } } class genTest(){ private Object object; public void add(Object object) { this.object = object; } public Object get() { return object; } }
The second genTest class has an invalid declaration in parentheses () .
In NetBeans 6.9.1, the code works correctly and returns false .
Product Version: NetBeans IDE 6.9.1 (Build 201007282301) Java: 1.6.0_21; Java HotSpot(TM) 64-Bit Server VM 17.0-b17 System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb) Userdir: C:\Users\Name\.netbeans\6.9
In Eclipse Indigo, the code output is:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: at genIntro.main(genIntro.java:4) Version: Indigo Service Release 1 Build id: 20110916-0149
Then manually compiling with the javac command, I get:
genIntro.java:12: '{' expected class genTest(){ ^ 1 error
This is rather strange, can someone explain why the difference is between them? Since it is wrong, why does it compile and run on Netbeans?
Running through javac genIntro.java
They all use jre6
Screenshot:

source share