Interface_InnerClass1 |
![]() Calling nested class |
Complete Codes:import java.io.*; import javax.swing.JOptionPane; import java.net.URI; public class ClassTemplate1 { /** * */ public ClassTemplate1() { // TODO Auto-generated constructor stub } public static void main(String[] args) throws Exception { // TODO Auto-generated method stub myClass mls = new myClass(); // can't instantiate abstract class try { myClass.aero2012 ae1 = mls.new aero2012(); ae1.welcome();ae1.freshman("Hello"); ae1.freshman("John Doe"); // } catch (NumberFormatException exc) { // } } }// end of class template // //outer class class myClass{ myClass(){} interface newStudent { public void welcome(); public void freshman(String str1); } //nested class public class aero2012 implements newStudent{ String dep1 = "Welcome To MIT"; String name = "Dept of Aerospace"; public void welcome(){ freshman( dep1); freshman( name); } public void freshman(String name) { System.out.println( name); } } } |
Runtime Views:
|