Java internal Class Analysis

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.