What is the correct syntax for java main method? - ProProfs Discuss
Advertisement

What is the correct syntax for java main method?

Asked by Wyatt Williams, Last updated: Apr 18, 2024

+ Answer
Request
Question menu
Vote up Vote down

3 Answers

Chris Evins

Chris Evins

Want to explore the world.

Chris Evins
Chris Evins, College Student, Schooling, Wolverhampton

Answered Dec 02, 2019

The correct answer to this question is Public static void main(String args[]). The syntax must include static, and the word string must be capitalized.

This syntax is regarded as the most important method of Java. This is because when one begins to learn Java, it is the first method that they will come across.

Though important, the method can be changed. The only way to change it is to change args to myStringArgs. Along with that, another way to write String args [] is string...args. Each part of the syntax is important.

upvote downvote
Reply 

g.Kenneth

g.Kenneth

g.Kenneth
G.Kenneth

Answered Apr 19, 2018

The correct syntax method for Java main is the public static void main, or (string[] args). This is often the first method of coding that Java students encounter. The “public” part of this method makes it run; if you don’t add that, you’ve automatically added restrictions that make it unable to run in any application. However, that’s not the only thing that’s important in this string. By making the first method a static method, it allows Java memory to catch up to the program and gets running before it gets into the more dynamic code chains.

However, like with all coding, Java can be easy to mess up by pressing the wrong key. Press something at the wrong time and ka-poof! All gone.

upvote downvote
Reply 

John Smith

John Smith

John Smith
John Smith

Answered Sep 15, 2016

Public static void main(String args[]) is the right format. String instead of string is the correct one.

upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.