1

Possible Duplicate:
What does “String[] args” contain in java?

I want to know the significance of the term written inside the bracket in definition of main function in java i.e.string[] args. What does it mean in public static void main(string[] args)? Is it always necessary to write it?

More over how many engines mysql server has and what is the default engine?

4
  • see this: What does “String[] args” contain in java? Commented Jul 4, 2011 at 4:20
  • @Eng.Fouad..As far as I know, command line arguments are those that we pass from the console but when we call main() method, we are not passing anything. Still not completely clear its significance. Commented Jul 4, 2011 at 4:27
  • @Chirag Fanse - if you don't add application arguments, then you pass an empty string array. That's at least something;) Commented Jul 4, 2011 at 4:30
  • Have you done any research to find this out?? Commented Jul 4, 2011 at 4:33

4 Answers 4

3

Public -> makes member accessible outside the class static -> allows main( ) to be called without having to instantiate a particular instance of the class void -> main() doesnt return value main(0 -> it is the method called when a Java application begins string[] args -> Its parameters. String args[ ] declares a parameter named args, which is an array of instances of the class String. In this case, args receives any command-line arguments present when the program is executed.

Sign up to request clarification or add additional context in comments.

Comments

2

public class MainClass{ public static void main(String[] args){} } When we run in the command line java MainClass

The JVM here tries to find a method main, We are basically accessing the method main outside the class and package so the method is Public. We are running this program by referring the class name and we are not creating any object,so to access the method without creating an instance it has to be static. JVM does not handle the output of the method and hence the return type is void. We can pass series of arguments through command line and String can enclose all the primitive type in Java and we do not know the number of arguments that can be passed so it declared with String array. For MySQL engine types please refer the link Engines

Comments

1

The Java contruct for main() is the equivalent of C's "void main(int argc, char **argv)". Java's main() receives an array of strings, from which one can obtain the length with args.length; no need for argc, the count. It can also be written "String args[]"; both ways specify an array of strings.

The mysql question rightly belongs in another SO question altogether.

Comments

0

As written , string shows that args variable is of type String and [] shows args is an array.

Inside main() is because, Main() is called whenever program is executed, So this args will hold everything you give it at run time i.e. at the call of main()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.