salam...this is oop
class ScopingExample {
int i=1;
public void firstMethod() {
int i=4, j=5;
this.i = i + j;
secondMethod(7);
System.out.println("In first method i = " + i);
}
void secondMethod(int i) {
int j =8;
this.i = i + j;
System.out.println("In second method i = " + i);
}
int getI() {
return i;
}
}
public class TestScoping {
public static void main(String[] args) {
ScopingExample scope=new ScopingExample();
scope.firstMethod();
System.out.println("In main method i = " +
scope.getI() );
}
}
class ScopingExample {
int i=1;
public void firstMethod() {
int i=4, j=5;
this.i = i + j;
secondMethod(7);
System.out.println("In first method i = " + i);
}
void secondMethod(int i) {
int j =8;
this.i = i + j;
System.out.println("In second method i = " + i);
}
int getI() {
return i;
}
}
public class TestScoping {
public static void main(String[] args) {
ScopingExample scope=new ScopingExample();
scope.firstMethod();
System.out.println("In main method i = " +
scope.getI() );
}
}
salam..
ReplyDeletebagus, sampai update blog pun gune programming language..all da best=)
demam programming
ReplyDeletesye suke programming tapi xscore pun