About Question enthuware.ocajp.i.v7.2.832 :
Posted: Sun Dec 08, 2013 10:50 am
Hello,
In this class where 'myValue' is a private member, how can I print it's value using dot notation on an intance of the class like this
System.out.println(ct.myValue)
???
In this class where 'myValue' is a private member, how can I print it's value using dot notation on an intance of the class like this
System.out.println(ct.myValue)
???
Code: Select all
public class ChangeTest {
private int myValue = 0;
public void showOne(int myValue){
myValue = myValue;
}
public void showTwo(int myValue){
this.myValue = myValue;
}
public static void main(String[] args) {
ChangeTest ct = new ChangeTest();
ct.showOne(100);
System.out.println(ct.myValue);
ct.showTwo(200);
System.out.println(ct.myValue);
}
}