basic java application developer sesi 2

19
Basic Java Application Developer Rudi Hartono Comlabs USDI ITB Sesi 2 Erwin Ginanjar Comlabs USDI ITB Sesi 2 - Java Application Developer

Upload: rudi-hartono

Post on 01-Jul-2015

166 views

Category:

Technology


0 download

DESCRIPTION

Slide pelatihan Java Application Developer 10 Sesi.

TRANSCRIPT

Page 1: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Basic Java Application Developer

Rudi HartonoComlabs USDI ITB

Sesi 2

Erwin GinanjarComlabs USDI ITB

Page 2: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Objektif

1. Mengerti dan familiar dengan bahasa pemrograman Java

2. Memahami konsep pemrograman berorientasi objek

3. Mampu menggunakan Integrated Development Environment Netbeans

4. Mampu membangun program aplikasi desktop berbasis GUI Java

Page 3: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Timeline Pelatihan

1 2 3 4 5 6 7 8 9 10

Sesi

Page 4: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Timeline Pelatihan

1 2 3 4 5 6 7 8 9 10

Sesi

Page 5: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Sesi 2

Lesson 3 : Tipe Data Sederhana• Tipe Data • Operasi Tipe Data• Fungsi dan Prosedur Operasi

Page 6: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Tipe Data

Jenis Tipe DataTipe Data PrimitifTipe Data Objek

Page 7: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Tipe Data Primitif

Integer – Bilangan BulatNama Deskripsi Ukuran/Format Rentang nilai Contoh nilai

Byte Byte-length integer

8-bit two’s complement

-128,..., 127 120

short Short integer 16 bit two’s complement

-32768,....,32767 5421

int Integer 32 bit two’s complement

-2147483648,...., 2147483647

536855

long long integer 64 bit two’s complement

9223372036854775808,..., 9223372036854775807

1526444L

Page 8: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Tipe Data Primitif

Real numbers – Bilangan pecahanNama Deskripsi Ukuran/Format Rentang nilai Contoh nilai

float Single-precision floating point

32 bit IEEE 754 1.7E-308,..., 1.7E-308

12.36F

double Double-precision floating point

32 bit IEEE 754 3.4E-308,....., 3.4E-308

22.37022.370D25.31e5

Page 9: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Tipe Data Primitif

Tipe lainNama Deskripsi Ukuran/Format Rentang nilai Contoh nilai

char Karakter tunggal 16-bit Unicode character

Seluruh karakter unicode

‘a’, ‘3’, ’*’

boolean Nilai boolean (true atau false)

True or false True or false truefalse

Page 10: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Operasi Tipe Data

Operator Penggunaan Deskripsi

+ Op1+op2 Op1 ditambah op2

- Op1-op2 Op1 dikurang op2

* Op1*op2 Op1 kali op2

/ Op1/op2 Op1 dibagi op2

% Op1%op2 Sisa dari op1 dibagi op2

++ Op++ Increment nilai op sebesar 1, evaluasi sebelum increment

++ ++op Increment nilai op sebesar 1, evaluasi setelah increment

-- Op-- Decrement nilai op sebesar 1

Page 11: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Program Operator Incrementpublic class OperatorInc{

public static void main(String args[]){int a=5;

System.out.println(a);

System.out.println(a++);

System.out.println(++a);

int b=5;

System.out.println(b);

System.out.println(++b);

System.out.println(b);}

}

Page 12: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Operator Logika Operator

>>=<

<===!=

&&||!&|^

Page 13: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Program Operator Logikapublic class OperatorLogika{

public static void main(String args[]){boolean hujan= true;

if(hujan){System.out.println(“Ibu ke pasar.”);

}

if(!hujan){System.out.println(“Ibu tetap pergi ke

pasar.”);}

}}

Page 14: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Program Arraypublic class ProgramArray {

public static void main(String args[]){int[] c = new int[5];c[0] = 1;c[1] = 2;c[2] = 3;c[3] = 4;c[4] = 5;

for(int i=0;i<5;i++){System.out.println(“Aray c ke-”+i+” adalah

”+c[i]);}

}}

Page 15: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Program Expressions, Statements, dan Blocks

public class OperatorExp {public static void main(String args[]){

double c = 2.0;System.out.println(“C = ” + c);

int a = 0;int b = 2;int d = 4;

int hasil = 0;hasil = a+b*d;System.out.println(“Hasil = ” + hasil);

hasil = (a+b)*d;System.out.println(“Hasil = ” + hasil);

}}

Page 16: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Program Expressions, Statements, dan Blocks

public class OperatorExp {

public static void main(String args[]){double c = 2.0;System.out.println(“C = ” + c);

int a = 0;int b = 2;int d = 4;

int hasil = 0;

hasil = a+b*d;System.out.println(“Hasil = ” + hasil);

hasil = (a+b)*d;

System.out.println(“Hasil = ” + hasil);

}}

Page 17: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Fungsi & Prosedur

Fungsi = meminta hasil / memberikan balikanProsedur = method yang tidak mengembalikan hasil.

tipe_data nama_fungsi(param1,param2,....param_n){//statement yang akan dieksekusireturn nilai_balik;

}

void nama_prosedur(param1,param2,....param_n){//statement yang akan dieksekusi

}

Page 18: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Program Fungsipublic class Fungsi {

static int hasil;static int tambah(int a, int b){

int c;c = a + b;return c;

}

public static void main(String args[]){int a=5;int b=6;hasil = tambah(a,b);System.out.println(“Hasil Penjumlahan ” + a + “ dan ” + b + “

adalah ” + hasil);

}}

Page 19: Basic Java Application Developer Sesi 2

Sesi 2 - Java Application Developer

Program Prosedurpublic class Fungsi {

static int hasil;static void tambah(int a, int b){hasil = a + b;}

public static void main(String args[]){int a=5;int b=6;tambah(a,b);System.out.println(“Hasil Penjumlahan ” + a + “ dan ” + b + “ adalah ” + hasil);

}}