Object-oriented (Local internal class and anonymous internal class)

Source: Internet
Author: User

/**
* Created by rabbit on 2014-08-05.
* When the internal class is defined locally,
* 1. It cannot be modified by a member modifier.
* 2. You can directly access members in the external class because they also hold
* References in the external class. However, it cannot access the local location of the object.
. Only local variables modified by final can be accessed.
*
* Anonymous internal class
* 1. An anonymous internal class is short for an internal class.
**/
Class outer4
{
Int x = 3;
Void method ()
{
Final int y = 5;
Class inner
{
Void function ()
{
System. Out. println (y );
}
}
New inner (). function ();
}

}
Public class innerclassdemo4 {
Public static void main (string [] ARGs)
{
New outer4 (). Method ();
}
}

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.