0% found this document useful (0 votes)
3 views5 pages

Smart Programming: Main Method Syntaxes

The document outlines various correct and incorrect syntaxes for the main() method in Java programming. It provides examples of valid and invalid declarations, emphasizing the importance of the correct structure for the main() method. Additionally, it includes contact information and links for Smart Programming, a training company based in Mohali and Chandigarh, India.

Uploaded by

rs9154040
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Smart Programming: Main Method Syntaxes

The document outlines various correct and incorrect syntaxes for the main() method in Java programming. It provides examples of valid and invalid declarations, emphasizing the importance of the correct structure for the main() method. Additionally, it includes contact information and links for Smart Programming, a training company based in Mohali and Chandigarh, India.

Uploaded by

rs9154040
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Smart Programming : Channel

An investment in Knowledge pays the best interest….

main() Method Syntaxes


Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> main() method syntaxes :-


-> public static void main(String[] args) - Correct
-> public static void main(Integer[] args) -
Correct syntax for method but incorrect syntax for
main() method
-> static public void main(String[] args) - Correct
because we can change the sequene of static and
public
-> public void static main(String[] args) -
Incorrect & Compile time error because method
syntax is incorrect as java needs always method
name after return type
-> public static void args(String[] args) or public
static void xyz(String[] args) - Correct syntax for
method but incorrect for main() method
-> public static void main(String[ ] args) -
Correct
-> public static void main(String [] args) -
Correct

1
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

-> public static void main(String []args) -


Correct
-> public static void main(String args[]) - Correct
-> public static void main(String args() {}) -
Incorrect
-> public static void main(String args) - Correct
syntax for method but incorrect syntax for main()
method
-> public static void main(String[] xyz) - Correct
-> public static void main(String... xyz) - Correct
(but there should be always 3 dots only)
-> protected/private static void main(String[]
args) - Correct syntax for method but incorrect
syntax for main() method
-> final public static void main(String[] args) -
Correct
-> synchronized public static void main(String[]
args) - Correct

2
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

-> strictfp public static void main(String[] args)-


Correct
-> public void main(String[] args) - Correct
syntax for method but incorrect syntax for main()
method (Error : Main method is not static in class
Test)
-> static void main(String[] args) - Correct syntax
for method but incorrect syntax for main() method

3
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

Company Links & Contacts

Company Name: Smart Programming (+91 62838-30308)

Address : Chandigarh & Mohali (Punjab), India

Websites: https://www.smartprogramming.in/
https://courses.smartprogramming.in

Android App:
https://play.google.com/store/apps/details?id=com.sma
rtprogramming

YouTube Channel:
https://www.youtube.com/c/SmartProgramming

You might also like