7 ways of declaring main in java

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.
 
551
1
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?
 

Related Threads for: 7 ways of declaring main in java

  • Posted
Replies
3
Views
3K
Replies
21
Views
3K
Replies
1
Views
489
  • Posted
Replies
6
Views
1K
  • Posted
Replies
9
Views
10K
  • Posted
Replies
1
Views
2K
  • Posted
Replies
9
Views
7K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top