answersLogoWhite

0

What is static void Main?

Updated: 8/11/2023
User Avatar

Wiki User

14y ago

Best Answer

The String array args refers to the arguments that the program may require before starting. In many cases you may want the program to take some values as input for processing. this string array is for that purpose.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

That will declare the main method in Java. When you run a Java program, this is the method which will be called first.

class AnyClass {

public static void main(String[] args) {

// execution code here

}

}

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

This is the main method in a Java program. When you run a Java program, execution begins in the main method. The command line arguments that you pass when you run it get passed to args:

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

public - This signifies the fact that - this method can be accessed by any class/method.

static - This keyword signifies the fact that, this method can be invoked without creating an instance of that class void - This signifies the fact that, this method would not return anything.

main - this is the method name string[] - data type of the parameter passed to the method args[] - the name of the parameter. we can pass any number of arguments to this method.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Each keyword in the main method's signature has a specific meaning.

  • main - name of the method - just like any other method
  • public - so that it can be freely accessed by the JVM
  • static - so that it can be accessed without the need to instantiate a class object
  • void - to ensure that the JVM does not expect this method to return anything
This answer is:
User Avatar

User Avatar

Wiki User

15y ago

void main() means the the main finction doesnot return ant value to the operating system .

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

public static void doesn't main anything. you have to put the storage class specifier "static" before the return type "void." public static void mains it will work.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is static void Main?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Is it compulsory to write static with void main?

Every C# application is started on the startup class' static Main method. Yes, it must be static, but void is not the only returned type. The 4 signatures:static void Main();static void Main(string[] arguments);static int Main();static int Main(string[] arguments);Ideally, there should be one and only one Main method in your application.


What are the valid signatures of the main method of a class?

The main method can be declared as either of the below: public static void main(String[] args) or public static void main(String args[])


What if you write static public void instead of public static void?

It would actually make no difference. The presence of the keywords during the declaration of the main method is important and not the order. so a static public void main(String[] args) would just compile and run perfectly fine just like public static void main(String[] args)


What is psvm in java?

public static void main


Is there any change by interchanging the position of main in Public static void main in java?

No. You can write it in as many ways as you want. The words public, static and void can be interchanged during the method declaration and still the main() method will continue to work in the same way. i.e., public static void main(String[] args) is the same as static public void main(String[] args) However, if you miss either of these 3 keywords from the method signature, the compiler will still let you compile the method, but it just won't be the main method that can be used to start the program execution.

Related questions

Is it compulsory to write static with void main?

Every C# application is started on the startup class' static Main method. Yes, it must be static, but void is not the only returned type. The 4 signatures:static void Main();static void Main(string[] arguments);static int Main();static int Main(string[] arguments);Ideally, there should be one and only one Main method in your application.


What are the valid signatures of the main method of a class?

The main method can be declared as either of the below: public static void main(String[] args) or public static void main(String args[])


What if you write static public void instead of public static void?

It would actually make no difference. The presence of the keywords during the declaration of the main method is important and not the order. so a static public void main(String[] args) would just compile and run perfectly fine just like public static void main(String[] args)


What is psvm in java?

public static void main


Is there any change by interchanging the position of main in Public static void main in java?

No. You can write it in as many ways as you want. The words public, static and void can be interchanged during the method declaration and still the main() method will continue to work in the same way. i.e., public static void main(String[] args) is the same as static public void main(String[] args) However, if you miss either of these 3 keywords from the method signature, the compiler will still let you compile the method, but it just won't be the main method that can be used to start the program execution.


How many types can write public static void main in java?

You can write it in as many ways as you want. The words public, static and void can be interchanged during the method declaration and still the main() method will continue to work in the same way. i.e., public static void main(String[] args) is the same as static public void main(String[] args) However, if you miss either of these 3 keywords from the method signature, the compiler will still let you compile the method, but it just won't be the main method that can be used to start the program execution.


Public static void main?

"Public" means that anyone can call the method "static" means that that it will not change "void" means that it will not return any value "main" is the actual name that the compiler looks for to run the program I hope this helps.


What is the Difference between public static void and static public void?

There is no difference between public static void and static public void


Can you have two mains in java?

Yes... We can have more than one main in JAVA... Just make the only one main method as public and other as default access specifier.... public class Test { public static void main(String args[]) { } } class Test1 { public static void main(String args[]) { } } class Test2 { public static void main(String args[]) { } } Just copy the above code and try.... Have fun in learning... :-) :) :-)


Why not write static public void main?

You can write. The order of these words does not make any difference.


If we interchange public static and void main then what happens?

Making main static is probably not a good idea; it may keep the linker from recognizing the program entry point. main is not a method, so it cannot be anything but public, for all intents and purposes. Declaring main to have a void return and/or with a void argument list is usually harmless, although it limits how your program can interact with the OS.


How static member function main in java can be accessed by another function?

The main method can be called just like any other method. Just keep in mind that doing so can create infinite loops. Example: class MyClass { static boolean hasEnteredMain = false; public static void main(String[] args) { System.out.println("main()"); if(hasEnteredMain) { return; } hasEnteredMain = true; f(); } static void f() { System.out.println("f()"); main(null); } }