Nested Classes in Java
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.nestedclass;
|
||||
|
||||
public class Enclosing {
|
||||
|
||||
public static class Nested {
|
||||
|
||||
public void test() {
|
||||
System.out.println("Calling test...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.nestedclass;
|
||||
|
||||
public class NewEnclosing {
|
||||
|
||||
void run() {
|
||||
class Local {
|
||||
|
||||
void run() {
|
||||
System.out.println("Welcome to Baeldung!");
|
||||
}
|
||||
}
|
||||
Local local = new Local();
|
||||
local.run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.nestedclass;
|
||||
|
||||
public class Outer {
|
||||
|
||||
public class Inner {
|
||||
|
||||
public void test() {
|
||||
System.out.println("Calling test...");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.baeldung.nestedclass;
|
||||
|
||||
abstract class SimpleAbstractClass {
|
||||
abstract void run();
|
||||
}
|
||||
Reference in New Issue
Block a user