hiding test

This commit is contained in:
mherbaghinyan 2018-05-14 11:49:03 +04:00
parent 5b7c29e7bf
commit 6adc92c451
3 changed files with 15 additions and 1 deletions

View File

@ -5,5 +5,9 @@ package com.baeldung.scope.variable;
*/
public class ChildVariable extends ParentVariable {
String instanceVariable = "parent variable";
String instanceVariable = "child variable";
public void printInstanceVariable() {
System.out.println(instanceVariable);
}
}

View File

@ -6,4 +6,8 @@ package com.baeldung.scope.variable;
public class ParentVariable {
String instanceVariable = "parent variable";
public void printInstanceVariable() {
System.out.println(instanceVariable);
}
}

View File

@ -8,5 +8,11 @@ public class VariableHidingDemo {
HideVariable variable = new HideVariable();
variable.printLocalVariable();
variable.printInstanceVariable();
ParentVariable parentVariable = new ParentVariable();
ParentVariable childVariable = new ChildVariable();
parentVariable.printInstanceVariable();
childVariable.printInstanceVariable();
}
}