mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
encapsulate fields: tests
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
public class A {
|
||||
static int getI() {
|
||||
return 23;
|
||||
}
|
||||
|
||||
static class B {
|
||||
static private int i = 42;
|
||||
|
||||
static int m() {
|
||||
return getI();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(B.m());
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class A {
|
||||
static int getI() {
|
||||
return 23;
|
||||
}
|
||||
|
||||
static class B {
|
||||
static private int i = 42;
|
||||
|
||||
static int m() {
|
||||
return getI();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(B.m());
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
public class A {
|
||||
public int i;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
public int getI() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
A a = new B();
|
||||
a.i = 23;
|
||||
System.out.println(a.i);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
public class A {
|
||||
public int i;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
public int getI() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
A a = new B();
|
||||
a.i = 23;
|
||||
System.out.println(a.i);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user