Java Programming with Netbeans IDE (JPNI)


JPNI:   SOLD       




Meeting 1

Compilation - Produces a .class (byte-module) extension, this is compatible so it can run on any OS.

//Percabangan
if (kondisi) {
//Kode perintah
}

else if (kondisi 2) {
//Kode perintah
}


Introduction to Java and Netbeans IDE

Meeting 2

public class Hallo {
//Ketik "psvm" lalu tekan Tab --- Digunakan untuk menampilkan fungsi main secara otomatis.
public static void main(String[] args) {

//Ketik "sout" lalu tekan Tab --- Digunakan untuk menampilkan instruksi print out secara otomatis.
System.out.println("hallo"); //Mencetak pesan hallo.
       }
}

How to Run Code

Right click - Run File is used to run the currently selected class module (within the scope of one package), while F6 is used to run all modules in one Project. (See the image above!)

A comparison of print out syntax between Java and C++ to display Strings and Variable contents is as follows:

  • + (in Java) 
  • << (in C++)

Exercise

Create a program to display the name of the day from the numbers (1...7) using branching.

Exercise Answers

//bundet.com
//Latihan Java, Percabangan

public class Percabangan {
 public static void main (String[] args) {
 int hari = 3;
 String namaHari = "";
 if (hari == 1) namaHari = "Ahad";
 else if (hari == 2) namaHari = "Senin";
 else if (hari == 3) namaHari = "Selasa";
 else if (hari == 4) namaHari = "Rabu";
 else if (hari == 5) namaHari = "Ahad";
 else if (hari == 6) namaHari = "Ahad";
 else if (hari == 7) namaHari = "Ahad";

 System.out.println("sekarang hari" + namaHari);
 }
}

Post a Comment

Previous Next

نموذج الاتصال