Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

main  RSS feed

 
sano vasu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Test
{
public static void main(String s1, String s2)
{
int i=10;
}
}

The above lines of code is not giving any compile time error but showing run time error does the compiler checks the syntax of main at compile time
or run time
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the compiler checks nothing at runtime. The runtime does though and your main is not of the correct format to be an application entry point, thus causing an error if you try to use this class as such.
 
Satish Kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At compile time only syntax of u r code is checked and main() is treated like any ordinary function . B ut at run time u r main(String[] arg) { -- }
is the starting point . Hence wen u say > java urjava.java the JVM looks for main of following
public static void main(String[] arg)
{ ----
-----
}
and as it is a STATIC funtion it is run automatically , without instabtiating the class. Now if in u r ptog if u have oerlaoded the main() func only at run time only the above main func will work .
 
Ryan McGuire
Ranch Hand
Posts: 1142
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by P.SATISH KUMAR:
At compile time only syntax of u r code is checked and main() is treated like any ordinary function . B ut at run time u r


I'm a native speaker of English and these "text message" abbreviations slow me down. I can only imagine how difficult this is to read for someone who isn't as proficiant with the language.

It takes three characters to type "u r" but only four for "your". Is your time really so valuable that you don't have time for the one extra character?

The form is getting in the way of the content. Here's my thought process: "Why should I care what this person has to say if he doesn't care how he says it?"

Ryan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!