201671010122 2013-2016-2 "I" and "inner class" of Java programming

Source: Internet
Author: User

"I" and "inner class"

This is the seventh week, and one semester has passed by half. What the teacher says is the core of Java Learning: Objects and classes, inheritance, interfaces. Lambda expressions and internal classes are nearing the end of the learning, recall that it is the core of Java, really difficult!

interface, lambda expression I think it is OK, not very abstract, plus the teacher explained again, basically have mastered. But in the inner class there, I fell into the abyss, completely ignorant of what it was all about. Looking at the handout, I probably know that the inner class defines a class in a class, as if it were a nested relationship, that the inner class can not only access its own data field, but also access the data field of the outer class object that created it, which sounds like a bit more powerful than a simple class function. The handout says that Java references an inner class because the inner class method can access data in the scope of the class definition, including private data, and inner classes can be hidden from other classes in the same package, and using anonymous inner classes is convenient when you want to define a callback function and do not want to write a large amount of code. The special syntax rules for inner classes do not seem to be difficult to understand, the biggest difference between a local inner class and an inner class is that it cannot be described with public or private access specifiers, its scope is scoped to the block that declares the local class, but when and under what circumstances the local inner class is used, I don't know. Just to understand its grammatical rules. The same is true for anonymous inner classes, only knowing that if you only need an inner class object and no inner class, then you don't have to name the class, static inner class, I only know using static declaration inner class.

"The syntax of the inner class is more complex, it violates the simple concept of Java design, it seems to add some beautiful interesting features, it is not necessary, as if Java also began to embark on many languages suffering from the destructive road", this is the description of the handout, I also think: the internal class compared to the conventional class has advantages, But also bring a lot of trouble, really do not understand why do not want to introduce this grammar, to him I just feel vaguely, like to understand actually do not understand. But then again, since Java references him, there must be a reason for him to persuade the public, but I do not understand this beginner, I hope that with the increase in my programming practice, can understand!!!

201671010122 2013-2016-2 "I" and "inner class" of Java programming

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.