Hi everyone, We always use main method in order to execute some metods ,statement or instance of any class. But in fact , I still do not know why we always write String args[] parameter. If anyone know the reason , please inform me.
If you execute a Java program from the command line (or by calling the main method in question directly), you can pass arguments into the main method to be processed by the method. For example:
Using this code you could concatenate two files into one larger file. From the command line you would call:
These three arguments would be passed to the main method as a String[] locally called args.
It's simply defined that way. If you start the "java" executable with a class name, it will look for a method declared as "public static void main (String[])" in that class to execute. It doesn't matter whether you actually have any parameters - you can't leave out the String array. This is very similar to how executables written in C work.
Hi, That statement is telling "U can not acces any nonstatic members by using static methods". i.e we can not call the non static method or members inside a static method.
Hi, That statement is telling "U can not acces any nonstatic members by using static methods". i.e we can not call the non static method or members inside a static method without creating object. But by creating an object , we can use it.