Blog for Learning

| lesson material | material summary | questions and answers | definitions | types and examples | other information | materi pelajaran | ringkasan materi | pertanyaan dan jawaban | definisi | jenis-jenis dan contoh-contoh | informasi lainnya |

Powered by Blogger.


Learning Java: The First Java Program You Must Create

After preparing the tools needed, then we try to make the first program.
Programs that will be made simple, only display messages to the screen.
This program is usually called the Hello World program .

Before Starting, Understand First the Concept

Java programming is actually very simple.
We only do this:
  1. Write code : Write code with Netbeans or other editor text.
  2. Compilation : Change the code to bytecode .
  3. Execution : Run the program

Now, Let's Start ...

First we have to make a project first in Netbeans.
Please follow the steps below:
  1. Navigate to the File menu then select New Project . In the window that appears, select Java Application then click next .
    Creating a New Project in Netbeans
  2. Fill in the project data, just replace the project name (Java Lab) and 'Create Main Class' do not need to be checked. After that click finish .
    Fill in project data

Making the Biar Rapi Package

We will save each java code in a package so that it is neatly organized and easy to find.
The package name will always change every time you meet. At this first meeting the package name is pertemuan1.
Making a package can be done by right clicking on the Source Package . Then select New > Java Package .
Creating java packages in Netbeans
In the window that appears, fill in the name of the package with pertemuan1After that, click Finish .
Fill in the package name

Creating a Program Code

Java programs are created in a class (class) .
Make a new class (Java Class) on the package pertemuan1.
In the window that appears, fill in the name of the class with PerkenalanAfter that click Finish .
Make sure : Use uppercase / capital letters at the beginning of the class name.
Then a new class will be named Perkenalan.
The gray text is a comment.
Just ignore it, because it doesn't affect the program that we make.
Usually used as additional information for programmers.
Meanwhile, it package pertemuan1indicates that this java code is in the package pertemuan1.
The introductory class starts with " {brackets then closes with " }brackets .
In that we will write the program code.
For example, please create a function main()in the class Perkenalan, it contains introductory text.
Function main()is the main function in a program. Functions that are mandatory in every Java program.
Function System.out.println("...");to display text to the screen.
We will use this function a lot to display output.
Now ... let's try execution.
Press ShiftF6to execute.
Well! easy right?
When we press ShiftF6, Netbeans automatically compiles and executes the program.
This is the advantage of using Netbeans.
We don't have to bother compiling it ourselves with the Command Line command.
0 Komentar untuk "Learning Java: The First Java Program You Must Create"

Silahkan berkomentar sesuai artikel

Template By Kunci Dunia
Back To Top