This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Sabtu, 12 November 2011

Contoh Program Package, Public dan Private

Contoh Program Package, Public dan Private

Contoh Program Package, Public dan Private
Langkah-langkah membuat programnya :
- Pertama buka Eclipse atau JCreator.
- File => New => Pilih Java Project/Project.
- Name Project Coba => Finish.
- Lalu File => Package => Name Package com.manusia.java.
- File => New Class => Name Class-nya Manusia.
- Lalu masukkan kodingan dibawah ini :
package com.manusia.java;
/*Manusia.java*/
public class Manusia{
    private String nama;
    private String jenkel;
    public void setNama(String nama){
        this.nama=nama;
    }
    public void setJenkel(String jenkel){
        this.jenkel=jenkel;
    }
    public void cetak(){
        System.out.println("Nama : "+nama);
        System.out.println("Jenis Kelamin : "+jenkel);
    }
}
- Buat Class lagi, File => New Class => Name Class-nya DemoManusia.
- Lalu masukkan kodingan dibawah ini :
/*DemoManusia.java*/
package com.manusia.java;
    public class DemoManusia{
        public static void main(String args[]){
            Manusia m = new Manusia();
            m.setNama("Andreas");
            m.setJenkel("Laki-laki");
            m.cetak();
        }
    }

Output :

 
  
Create By : Andreas Bistok Parningotan