Java compilation error "No enclosing instance of type AA is accessible. must qualify the allocation with an enclosi

Source: Internet
Author: User

This is because AA is a dynamic internal class. To create such an object, an instance must correspond to it,ProgramThis error is reported when a dynamic internal class is called directly in a static method. Such errors are similar to static methods in the class. dynamic methods cannot be called directly. You can declare the internal class as static. Or do not call it in a static method.

So why can't non-static methods call dynamic methods? From an object-oriented perspective, dynamic methods are closely related to objects. For example, launching is a method, it is associated with the car object, so only the new car object can execute the car. launch

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.