The class declaration in the inner classes is different, the effect is not the same

Source: Internet
Author: User

1. A declaration in a class, a declaration in a method of a class. An inner class is declared inside a method in a class, and an inner class in its method calls a variable outside the inner class, and the variable must be final

class outter{int x1 = 0;public void print () {final int x1 = 0;class inner{public void Innerprint () {System.out.println (x1+ 1);}}} Class Inner2{public void Inner2print () {System.out.println (x1+ "");}}

  

The class declaration in the inner classes is different, the effect is not the same

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.