Monday, September 15, 2014

Contoh Class Java Netbeans

7:54 PM Posted by beckti'velu No comments
package javaapplication6;

class Serigala {
    public String nama;
    public String warna_bulu;
    public void mengaung () {
        System.out.println("Auuuuuu");
    }


 
    public void info() {
        System.out.println("Alamat:"+this);
        System.out.println("Nama :"+this.nama);
        System.out.println("Warna Bulu :"+this.warna_bulu);
     
    }
 
}

public class JavaApplication6 {

 
    public static void main(String[] args) {
         Serigala mamoon = new Serigala();
         mamoon.nama = "Mamoon";
         mamoon.warna_bulu = "Hitam Pekat";
       
         Serigala maikel = new Serigala();
         maikel.nama = "Mamoon";
         maikel.warna_bulu = "Hitam Pekat";
       
         Serigala serigalagua = maikel;
         serigalagua.nama = "Michael";
       
         mamoon.info();
         maikel.info();
         serigalagua.info();
    }
 
}

0 comments:

Silahkan Tinggalkan Komentar Anda