It’s a very simple program asked in interviews from freshers to 2 year experienced developers, but will check your basic knowledge.
combinations of public static void main in java?
public static void main method(String...args) is entry point for program in java
Below both are same thing
public static void main (String[] a) //with string array
|
Below both will work fine because public and static are just access modifiers that can be applied to method, they can be applied in any order.
public static void main (String...a) //with varargs
static public void main(String...a) //Fine
|
You can’t change order of void (return type) and main
//public static main void (String...a) //error
|
Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.
Related >
Access modifier /Access specifier in java - private, package-private(Default), protected and public - Diagram and tabular form
Arrays in java - Declare, Initialize, display, add values and iterate on 1D(One Dimensional), 2D (Two Dimensional) and jagged (Ragged) Arrays
Labels:
Core Java
output java programs