Fundamental() Method in Java

Fundamental() Method in Java

fundamental() strategy is beginning execution square of a java program or any java program begin their execution from primary technique. On the off chance that any class contain primary() strategy known as principle class.

Syntax of main() method:


public static void main(String args[]) 
                    { ....... 
                      ....... }


open is a watchword in a java dialect at whatever point in the event that it is gone before by primary() technique the extension is accessible anyplace in the java environment that implies fundamental() strategy can be executed from anyplace. primary() technique must be gotten to by each java developer and thus whose entrance specifier must be open.


static is a catchphrase in java on the off chance that it is gone before by any class properties for that memory is dispensed just once in the system. Static strategy are executed just once in the project. primary() strategy for java executes just once all through the java program execution and thus it proclaim must be static.


void is an extraordinary datatype otherwise called no arrival sort, at whatever point it is gone before by principle() technique that will be stay away for the indefinite future any quality to the working framework. principle() strategy for java is not giving back any worth and thus its arrival sort must be void.

String args[]

String args[] is a String cluster used to hold charge line contentions through String values.

In the event of principle() technique taking after changes are satisfactory

  1. We can announce String[] in any substantial structure.
String[] args

String args[]

String []args
  1. Occasion of String[] we can take var-arg String parameter is String…
main(String[] args) --> main(String... args)
  1. We can change the order of modifiers i.e Instead of

public static  we can take  static public

  1. Instead of args we can take any valid java identifier.
public static  void main(String a[])



We can over-burden primary() strategy ?

Yes, We can over-burden primary() strategy. A Java class can have any number of fundamental() techniques. However, run the java program, which class ought to have primary() technique with signature as “open static void main(String[] args). On the off chance that you do any change to this mark, aggregation will be fruitful. However, not run the java program. we will get the run time mistake as fundamental technique not found.Case of supersede fundamental() technique


public class mainclass {
 public static void main(String[] args)
 { System.out.println("Execution starts from Main()"); 
 void main(int args) 
 { System.out.println("Override main()");
 double main(int i, double d) 
 { System.out.println("Override main()"); return d; }


Execution starts from Main()


Leave a Reply