Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
JavaQ5b
//JAVA LAB Q5-B-Write a Java Program to demonstrate use of nested class. //-------------------INNER 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 int outer_private = 30; // inner class class InnerClass { void display() { // can access static member of outer class System.out.println("outer_x = " + outer_x); // can also access non-static member of outer class System.out.println("outer_y = " + outer_y); // can also access private member of outer class System.out.println("outer_private = " + outer_private); } } } class Rextester { public static void main(String args[]) { OuterClass outerObject = new OuterClass(); OuterClass.InnerClass innerObject = outerObject.new InnerClass(); innerObject.display(); } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
LRU cache - Simple solution (costly)
a+b
JAVA İLE CELCIUS HESAPLAMA - Fahrenheit to Celsius with Java
boundary vs core
Count Islands
home by stars
3.F
OBF-7 PR
dfkbzhfvjahfjh
classwork
stackse - search stackoverflow differently
Please log in to post a comment.