answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How many types can write public static void main in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How to Write a java program to display hello?

public class Hello{public static void main(String [] args){System.out.println("Hello");}}


Can you interchange the term public and static in java?

The two are different, and independent from one another. A variable can be public, static, both public and static, or neither.


What is psvm in java?

public static void main


Write a program to show the concept of recursion in java?

public class Main{ public static void main(String[] args){ System.out.println("the factorial of 5 is: " + getFactorial(5)); } public static int getFactorial(int num){ return num + getFactorial(num-1); } }


What is public static final variable in java?

-Public to all - Static to access with Class Name - Final to change( constant and not alowed to change) Just use it along with class name. (As implied above, a 'public static final' variable in Java is what other languages would call a Constant. )


In java public static voidmain function denotes what?

Java's main function denotes the entry point into the execution of your program.


Write a program in java programming language to print welcome to java programming?

public class welcome { public static void main (String args[]) { System.out.println("Welcome to Java programming"); } } There are also many "Hello World" tutorials you can find elsewhere on the internet


What is the error in exception handling in java with example?

class Demo { public static void main(String s[]) { System.out.println("hello java frm Demo"); } } class Demo1 { public static void main(String s[]) { System.out.println("hello java frm Demo1"); String z={" "}; Demo.main(); } }


Write a Java program to generate a copy of itself?

public class S{public static void main(String[]a){String o="public class S{public static void main(String[]a){String o=%c%s%c;System.out.printf(o,34,o,34);}}";System.out.printf(o,34,o,34);}}


Write a java program to pass a string have a good day from command line?

public class HaveAGoodDay { public static void main(String[] args) { for (final String arg : args){ System.out.print(arg +" "); } } } compile and run the program: java HaveAGoodDay have a good day. output: have a good day.


Write a java program that prints all alphabets?

class TestApp { public static void main(String args[]) { char ch; for( ch = 'a' ; ch <= 'z' ; ch++ ) System.out.println(ch); } }


How do you invoke static methods?

if some method is static, then you can not call that method through the oobject of that class. but the name of the class. let us see a example: class Test { int a; int b; static void show() { System.out.println("we are in show"); } } class Main { public static void main(String args[]) { Test t=new Test(); t.show();\\thiss is an erroraneous code. because, the method "show()" is static. Test.show();\\this is correct } Arnas Sinha