Quote:
Originally Posted by insanesk8123 Here is a simple script that when run displays "Hello World!" into the commands prompt. More will be explained about it after. Code: public static Hello
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
"public static Hello" is defining the class to be:
public (Can be accessed by other classes)
static (can be access inside this file)
and to be named "Hello" (NOTE!: your file must be named the same as the class that contains the main method header, which in this case would be the Hello class) "public static void main(String[] args)" is the main method header, any file that will be ran will need this method.
public (can be accessed by other classes or methods)
static (can be accessed by the rest of this class or other methods in this class)
void (the method's return type) I must go for now but soon I will post a guide on compiling and running a java class file in a windows OS.  |
Actually, you're wrong about half of the stuff in this post.
First off, "public static Hello" will not compile. You can't have a static modifier on a class, only public, abstract, and final.
Secondly, you said "static (can be accessed by the rest of this class or other methods in this class)" which is entirely wrong. The static modifier on a method in a class means that it can be accessed by anything, take for instance the Integer.parseInt(int x) method, which is static.
Anyway, you definitely don't deserve rep for this.