PDA

View Full Version : Syntax Definitions


BWiz
09-11-2008, 05:47 AM
I've been doing a couple of Java tutorials that I've found online, however none of them seem to sufficiently explain some of the syntax that I am using. I don't really want to leave a hole in my knowledge, so I was wondering if someone could explain what some of these keywords (not sure of what term to use when referring to them) mean.


public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello, World!");
}
}
If somebody could explain what all the highlighted words mean, I would appreciate it greatly. Also, any in depth tutorials for beginners would be good too. Thanks in advice.

brad211987
09-11-2008, 05:17 PM
public: This is an access keyword used to define what type of access other objects have to your class and its methods. public will let any objects create an instance of your class and use its public methods. There is also Private that restricts access to the current class, and Protected which restricts access to classes in the same package as your class.

static: This defines class attributes/methods/variable. In simple terms, this means that there is only one main method across all of the instances of your class.

void: This is the return type for the method. Void means that the method does not return anything.

{String[] args}: This is the argument list for the main method. The main method takes a String Array(String[]) of arguments, and "args" is the variable that references that array.