Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

public in main method

Status
Not open for further replies.

munnanext

Programmer
Aug 20, 2004
49
US
Hi i am writing a mock exam, and the output they are saying is not the same when i am compiling the program.
The program is as follows:

class XTC {

static void main ( String [ ] args ) { // ---line 1
int x = true ? 10 : 20 ; // ---> line 2
System . out . println ( x ) ; // ---line 3
}
};
Here they are giving the answer that this program will compile and give an output of 10 without issuing any warnings or errors.

But when i compiled this program, the program is compiling but at run time it is giving an error that "main method not public"
Thanks in advance.
 
To run a class from the command line, the entry point MUST follow the signature :

public static void main(String args[]) {}

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top