Part 2
Looking at hello world.
Here is out basic hello world script.
Code:
class nexx {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Its very basic and easy to understand.
Lets look at it line by line.
Heres the first line.
What this is is it tells java what class it is going to make when it compiles. Don't worry we will talk more about this later for now just remember that the class name must be the file name for example this would be called "nexx.java".
Heres our second line.
Code:
public static void main(String[] args) {
This is a method for now just note that the method called main is automatically executed.
Heres out third line where all the magic happens.
Code:
System.out.println("Hello World!");
The "out" in this code means that it will output something to the console the "println" says print this with these parameters on a new line. Notice that using "print" would print on the same line as the last one instead of a new line.
and the closing brackets for the opening brackets. (Note: You always must have the same amount of opening brackets as you do closing.)
Now lets get to executing this program. Open up that eclipse program that you set up earlier and just click next and use the defaults for all settings.
Make a new project using file-new-java project and call it whatever and make a new class with file new class and call it "nexx" and leave the rest default.
Copy and paste all of the script that is up there into the main box and click the green play button. If asked press "Java application". Then in the box below you should see "Hello World!".
Congrats you have just made your first java program.