/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tugaskuliah;
/**
*
* @author a42f
*/
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tugaskuliah;
/**
*
* @author a42f
*/
//initial nama class
public class This1 {
int i = 0;
//memulai penggunaan kata "this" dalam sebuah method penjumlahan
void increment(int i){
this.i = this.i+i;
}
//memulai penggunaan kata "this" dalam sebuah method pengurangan
void decrement(int i){
this.i = this.i-i;
}
void increment(int i){
this.i = this.i+i;
}
//memulai penggunaan kata "this" dalam sebuah method pengurangan
void decrement(int i){
this.i = this.i-i;
}
//method print / menampilkan hasil yang akan ditampilkan
void print1(){
System.out.println("i = " + i);
}
void print2(){
System.out.println("i = " + i);
}
public static void main (String [] args){
This1 a = new This1();
a.increment(5);
a.increment(8);
a.print1();
a.decrement(5);
a.decrement(8);
a.print2();
}
}
void print1(){
System.out.println("i = " + i);
}
void print2(){
System.out.println("i = " + i);
}
public static void main (String [] args){
This1 a = new This1();
a.increment(5);
a.increment(8);
a.print1();
a.decrement(5);
a.decrement(8);
a.print2();
}
}
Tidak ada komentar:
Posting Komentar