Happy New Year To All my visitors and friends who visited my website. I has been a while since I was able to post new sample program in my website because of my hectic schedule. Anyway in this article I would like to share with you a sample program that I wrote in Java to demonstrate how inner class works in Java programming language. The code is very simple just to demonstrate how it works.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author Jacob pomperada
* Example of Inner Class in Java
* January 9, 2017 Monday
*/
class Outer_Class_Demo {
// inner class
private class Inner_Demo {
public void display_result() {
System.out.println("\n");
System.out.print("\t Inner Class in Java Example");
System.out.println("\n");
System.out.println("This is an inner class demonstration in Java");
System.out.println();
System.out.println("End of Program");
System.out.println();
}
}
void Display_Inner_Class() {
Inner_Demo inner_class = new Inner_Demo();
inner_class.display_result();
}
}
public class JavaApplication1 {
public static void main(String args[]) {
Outer_Class_Demo outer_class_demo = new Outer_Class_Demo();
outer_class_demo.Display_Inner_Class();
}
}