+ 1

[DUPLICATE] public static void main(String args[]) why we need to write it ? and what does it mean?

12th Jul 2016, 4:09 AM
Umamaheswararao Tumma
Umamaheswararao Tumma - avatar
5 Answers
+ 1
public: when we write it, we make the whole program and all its datatypes like int etc. and member functions accesible from anywhere static: static is a keyword and it doesnt have a huge significance but u can look it up on wiki void: void shows that we are not passing anything like data or something while starting the program.. i.e. initially the program is blank. main:the most imp. part of any java or c or c++ program is main. main is a method and every program be it of 10 lines or 100000 lines will have to have a main method. The basic info of a program is stored in main method. Sting args represents that we are passing arguments inside the program
12th Jul 2016, 6:53 AM
Priyanshu Kumar
Priyanshu Kumar - avatar
+ 1
tqâ˜ș
12th Jul 2016, 7:00 AM
Umamaheswararao Tumma
Umamaheswararao Tumma - avatar
+ 1
I'll answer what is left to answer. Static : We can access a Class variable by using the name of the Class, and not necessarily using a reference to an individual Object within the Class.Static variables can be accessed even when no Objects of that Class exists. Class variables are declared using the static keyword. In simple words, you don't need an object to call the main method just a class in which the main method is. Hope I could explain. And about the arguments of the main method. We write String[] args to let the computer know that we are writing code in string format or plain English.
12th Jul 2016, 10:13 AM
Ashwani Jha
Ashwani Jha - avatar
0
For simplicity I'll just say every program needs a starting point. Something that has to be run first in order to run the rest. In the case of Java, this is done with the main method. You'll understand the variables as you understand Java more and more
12th Jul 2016, 5:55 AM
James
James - avatar
0
is a main method to run the program
17th Jul 2016, 5:21 PM
vinrosales