Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

public static void main (String[] args).....why??

843789May 29 2010 — edited May 30 2010
hello folks,
this is my first post.
I´ve been learning java on my own for a few days now.

questions:

1.
is it always necessary to have the following words preced the main method?
public static void
what does each one mean?
is it necessary to write them always in the same order?

2. the arguments of the main method go in between parenthesis, right?
Are they always String[] args??

so far in the examples I have tried, the main method uses numeric values for variable x, but the arguments are still String[] args

example:

public class Practice
{

public static void main(String[] args)
{

// degree= angle
// angle= in radians

double angle, degree, a;
degree= 180 ;
angle= (degree*2*Math.PI)/360;


a= Math.sin(angle);

System.out.println(a);

}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2010
Added on May 29 2010
5 comments
925 views