I have this code in a single 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 class genTest has a wrong declaration seen with the brackets ().
In Netbeans 6.9.1 the code runs correctly and outputs 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 outputs :
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 via the javac command I get :
genIntro.java:12: '{' expected
class genTest(){
^
1 error
This is rather strange, can someone explain why the difference between them? Since it’s erroneous why does it compile and run in Netbeans?
Running via javac genIntro.java
They all use jre6
Screenshot :

I tried it with javac 7 from the command-line and NetBeans 7.1, and it gives the same error as your javac example in both. Are you sure the source is the same in your netbeans version? I can’t see how it would compile at all.
Changing the line “class genTest(){” to “class genTest {” allows it to compile, and prints ‘false’.