Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
JavaQ5
//JAVA LAB Q5-A-Write a Java Program to demonstrate use of nested class. //----------------STATIC NESTED CLASS------------------ import java.util.*; import java.lang.*; class OuterClass { // static member static int outer_x = 10; // instance(non-static) member int outer_y = 20; // private member private static int outer_private = 30; // static nested class static class StaticNestedClass { void display() { // can access static member of outer class System.out.println("outer_x = " + outer_x); // can access display private static member of outer class System.out.println("outer_private = " + outer_private); // The following statement will give compilation error // as static nested class cannot directly access non-static membera // System.out.println("outer_y = " + outer_y); } } } class Rextester { public static void main(String args[]) { OuterClass.StaticNestedClass nestedObject = new OuterClass.StaticNestedClass(); nestedObject.display(); } }
run
|
edit
|
history
|
help
0
Count and Say
Switch
Circular array Loop?
// Java Coding Challenge - 09: Find out duplicate numbers using Array
Java Object Graph Dumper (iterative)
Ifelsenested
Ridhiverma
상속2
right swastik
java palindrome check