Package org. wangfy. Dev. Lang. innerclass;
/**
*
* Outterclass. Java
*
* @ Author fuyewang E-mail: willfcareer@sohu.com
* @ Version 1.0 creation date: 09:18:12
* @ Since 1.0
*
*/
Public class outterclass
{
Private int I = 0;
Private string S = "ABC ";
/*
* This is static nested class
*/
Private Static class staticnestedclass
{
Private void yell ()
{
System. Out. println (this. tostring ());
// Outterclass. This. Yell (); // The static internal class instance does not reference the external class instance.
}
}
/*
* This is inner class
*/
Private class innerclass
{
Private void yell ()
{
System. Out. println (this. tostring ());
Outterclass. This. Yell (); // The internal class instance explicitly uses the external class instance method.
}
}
Private void yell ()
{
System. Out. println (this. tostring ());
}
Private void run (int I)
{
/*
* This is local class
*/
Class localclass
{
Public void yell ()
{
System. Out. println (this. tostring ());
}
}
/*
* This is Anonymous class
*/
New object ()
{
Public void yell ()
{
// I = 3; // The anonymous internal class cannot reference or change the non-final parameter passed in from the external class
// System. Out. println (I );
Outterclass. This. I = 2;
Outterclass. This. S = "BCD ";
System. Out. println (outterclass. This. I );
System. Out. println (outterclass. This. s );
System. Out. println (this. tostring ());
}
}. Yell ();
Localclass lc = new localclass ();
Innerclass Ic = new innerclass ();
Staticnestedclass SC = new staticnestedclass ();
LC. Yell ();
IC. Yell ();
SC. Yell ();
}
Public static void main (string [] ARGs)
{
Outterclass OC = new outterclass ();
OC. Run (3 );
}
}
For final type variables, see
Http://blog.csdn.net/axman/archive/2006/12/25/1460544.aspx