Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Mememe {
- private static int m_AccessableInt; // доступно в StaticNestedMememe
- private int m_NotAccessableInt; // не доступно в StaticNestedMememe
- [...]
- public static class StaticNestedMememe {
- [...]
- }
- }
- Mememe.StaticNestedMememe nestedObject = new Mememe.StaticNestedMememe();
- public class Mememe {
- public void calc(String requestPath) {
- class Сalculator{
- int calc() { return 0; }
- }
- }
- }
- new Thread(new Runnable() {
- public void run() {
- ...
- }
- }).start();
- public class OuterClass {
- public void method() { ... }
- public class InnerClass {
- public void method() { ... }
- public void anotherMethod() {
- method();
- }
- }
- }
- OuterClass outer = new OuterClass();
- OuterClass.InnerClass innerClass = outer.new InnerClass();
- public class Example {
- public static int si = 0;
- private static int psi = 0;
- public final Inner inner;
- public int i = 0;
- private int pi = 0;
- public Example() {
- inner = new Inner();
- }
- public static class Nested {
- int e;
- public Nested() {
- e = Example.psi;
- e = Example.si;
- // а вот так нельзя
- // e = Example.this.pi;
- // e = Example.this.i;
- }
- }
- public class Inner {
- int e;
- public Inner() {
- e = Example.psi;
- e = Example.si;
- e = Example.this.pi;
- e = Example.this.i;
- }
- }
- }
- class ExampleTwo {
- // Nested можно сразу
- Example.Nested nested = new Example.Nested();
- Example.Inner inner;
- {
- // так нельзя, нужен объект Example
- // inner = new Example.Inner();
- // а так можно
- Example example = new Example();
- inner = example.inner;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement