7 ways of declaring main in java

  • #1
josephaswin
1
0
hi,

i know there are 7 ways to declare main in java
as

1.public static void main(String args[])
2.static public void main(String args[])

but what are the other ways?

but only change first two keywords
i.e. public and static
and use the required keywords.

this is the question given to me.
 

Answers and Replies

  • #2
Nylex
552
2
Apparently you can declare main() as private or protected, too. The code will compile, but you'll get an error when you run the program saying main() isn't public. I didn't know that. Also, I don't think you can remove "static" as you'll get an error when you try to compile if you do. Why do you want to declare main() in different ways anyway?
 

Suggested for: 7 ways of declaring main in java

Replies
14
Views
144
Replies
15
Views
859
Replies
1
Views
931
Replies
3
Views
1K
Replies
37
Views
4K
Replies
23
Views
942
  • Last Post
Replies
4
Views
1K
  • Last Post
Replies
10
Views
1K
  • Last Post
Replies
10
Views
2K
Top