Java Inner class--local inner class

Source: Internet
Author: User

The local inner class, which is placed in "{block}", is a local inner class that cannot be modified by the member modifier static, and the members of the inner class cannot be static.

Accessing the local variable "{block}" in the inner class requires that the local variable be declared final.

Members of external classes can be accessed directly because they also hold references in external classes.

However, you cannot access the variables in the block in which it resides, only the final decorated local variables (including the formal parameters).

Anonymous inner class

Premise: The inner class must inherit one or implement an interface. But all classes have a common base class Object, so when using anonymous classes, you can also not display the life of a base class (in fact, the base class itself exists)

Inner classes can also be saved with a base class and then called methods.

Java Inner class--local inner class

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.