Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7430285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:06:53+00:00 2026-05-29T09:06:53+00:00

I have this code in a single file : public class genIntro { public

  • 0

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 :

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:06:54+00:00Added an answer on May 29, 2026 at 9:06 am

    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’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a greasemonkey user script with this single line of code... window.close(); but
I have this code #include <iostream> using namespace std; int main(int argc,char **argv) {
I'm working on legacy code that looks very similar to this: public class BaseParser
I have the following code in a header only file. #pragma once class error_code
I have the following snippet of code. abstract class MrParent { public function __construct()
I have here this code. I want it to first display an image file
Consider the following code parts: this is Timing.h: class Timing { public: //creates a
I have this code in jQuery, that I want to reimplement with the prototype
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
I have this code that performs an ajax call and loads the results into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.