Hi,
After the IDE setup, please open NetBeans.
- Create a new project. File > New Project from the top menu.
- Select a Java Application then click next.
- Project Name: HelloWorld then click finish.
As
you can see below, notice that the file name HelloWorld.java is the
same with the class name HelloWorld. This is one important thing to
remember in JAVA.
Let us take a look with the above code.
Let us take a look with the above code.
To create a comment in your code.
1 | //A single line comment.
|
2 | /* A
|
3 | multiple line
|
4 | comment */
|
In the method main(String[] args), it is where your program starts. (Program starting point)
Try to add a line of code like the figure below. To run your application, press F6 or click the play icon above.
You can see the output on the Output tab below.
You can see the output on the Output tab below.
Let us look at the code structure.
public class HelloWorld { //this is a class, it is like a code segment or group, it starts with a curly brace {
//inside the class HelloWorld is a method/function, it is also like a code segment or group
public static void main(String[] args) { //this is main(), this is the program starting point.
//inside this will be your codes.
}
}//this is the end of the class HelloWorld it ends with a curly brace }
Let us take a look at the figure below.
In NetBeans, you can easily identify syntax errors like the above one. You can point your mouse into the Exclamation Mark and see the error. The error is you lack a semicolon in the end of your code statement System.out.print(“Hello World”);
And were done! Feel free to ask any questions by posting your comments below. We will answer it at the quickest time!
Next: Java Variables
No comments:
Post a Comment