Method, Array

Posted on Updated on

1.Class Java Method
public class JavaMethod{
public void cetak(String param){
System.out.println(“>>” + param);
}
public int jumlah(int a, int b){
cetak(“DALAM method jumlah()”);
return a+b;
}
public static void main (String args[]){
JavaMethod m=new JavaMethod();
m.cetak(“Hello Method”); //Argument
m.cetak(“Oke..”);
m.cetak(“Hasil : ” + m.jumlah(10,10));
}
}
2.Class Method_Overloading
public class MethodOverloading{
public void cetak(String param){
System.out.println(“>>” + param);
}
public void cetak(String judul, String isi){
cetak(judul.toUpperCase());
cetak(isi);
}
public int jumlah(int a, int b){
cetak(“DALAM method jumlah()”);
return a+b;
}
public static void main (String args[]){
MethodOverloading m=new MethodOverloading();
m.cetak(“Hello Method”); //Argument
m.cetak(“Oke..”);
m.cetak(“Hasil : ” + m.jumlah(10,10));
m.cetak(“Java programming”, “java is 100% OOP!”);
}
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s