1 / 10

Pengenalan OOP Java

Praktikum OOP Java (IX307). Pengenalan OOP Java. Struktur Program Java (1). Source program Java SELALU terdiri dari kelas-kelas (paling sedikit satu kelas di setiap file program) Jika sebuah source / file program memiliki beberapa kelas, maka hanya ada 1 kelas yg bersifat public

Download Presentation

Pengenalan OOP Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Praktikum OOP Java (IX307) Pengenalan OOP Java

  2. Struktur Program Java (1) Source program Java SELALU terdiri dari kelas-kelas (paling sedikit satu kelas di setiap file program) Jika sebuah source / file program memiliki beberapa kelas, maka hanya ada 1 kelas yg bersifat public Nama kelas public = Nama file File program Java mempunyai extension .java

  3. Struktur Program Java (2) Didalam sebuah kelas terdapat : Atribut (data) Method (fungsi/prosedur) contoh: public class Mahasiswa { String NRP; //atribut String Nama; int no_komputer; public String getNama() { //method return Nama; } }

  4. Struktur Program Java (3) Program java memiliki sebuah fungsi khusus yg bernama main(). Program akan dieksekusi mulai dari fungsi main contoh: public class Mahasiswa { String NRP; //atribut String Nama = “Tommy”; int no_komputer; public String getNama() { //method return Nama; } public static void main(String[] args) { Mahasiswa mhs = new Mahasiswa(); System.out.println("Hello " + mhs.getNama() + " selamat belajar java!"); } }

  5. Pemrosesan Program Java Program java dicompile dengan cara : D:\>javac Namaprg.java Program java dijalankan dengan cara : D:\>java Namaprg

  6. Tipe Data (1) Integer byte : 1 byte (8 bits) di memori short : 2 bytes (16 bits) di memori int : 4 bytes (32 bits) di memori long : 8 bytes (64 bits) di memori

  7. Tipe Data (2) Floating point float : range nilai dari -3.4E38 (-3.4 x 1038) ke +3.4E38 (+3.4 x 1038), 4 bytes di memori double : range nilai dari -1.7E308 (-1.7 x 10308) ke +1.7E308 (+1.7 x 10308), 8 bytes di memori

  8. Setting Java • Install jdk (jdk-6u6-windows-i586-p) • Masukkankedalam path & Classpath: • KlikkananmyComputer -> Properties -> Tab Advanced -> Environment Variables • Cari environment variabel PATH -> klik Edit, kemudiantambahkan : ; C:\Program Files\Java\jdk1.6.0_03\bin (sesuaikandenganhasil install dikomputeranda, tanda ; sebagaipemisahdengan PATH lain) • Cari environment variabel CLASSPATH -> klik Edit, kemudiantambahkan : ; . (titikkoma, dantitik=current directory) • Jikabelumadaklik New, isi Name : CLASSPATH, dan value : ; .

  9. EditPlus2 • Install Editplus2 • Copykan file tool.ini ke folder hasil install editplus, biasanyadi : C:\Program Files\EditPlus 2 • Cara mengkompilasi program : Tools -> Java-Compile atau Ctrl+1 • Cara menjalankan program : Tools -> Java-Run atau Ctrl+2

  10. Netbeans • Install jdk (install sajatidakperlu setting PATH dan CLASSPATH) • Install Netbeans • Membuat Project baru : • Pilih menu File -> New Project -> Projects: Java Application -> klik Next • Isinama project & tentukanletak project • Buangcentang Create Main Class -> klik Finish • Klikkanan Source Packages -> New -> Java Class • Masukkannamakelas -> klik Finish

More Related