The idea of Java programming-Anonymous inner class

Source: Internet
Author: User

This article uses an example to deepen the understanding of anonymous inner classes.

Topic:

Package object-oriented; interface In{void method ();} Class test{//complements the code by anonymous inner class}public class Unknownnameclass {public static void main (string[] args) {test.function (). method ();}}

Analyze This sentence test.function (). method ();

In the test class there is a static method function () without parameters, the return value is not determined first, and this method calls the methods method, indicating that the return value of the function is an object that can call method methods, then is the subclass of in. An anonymous subclass object in which the function should return in.

The supplemental code is as follows:

public static in function () {return new in () {public void method () {//TODO auto-generated Method stub}};}

Upward downward, forward backward reasoning is very necessary in programming, need to strengthen the practice.

This article is from the "line of the World" blog, please be sure to keep this source http://4259297.blog.51cto.com/4249297/1656474

The idea of Java programming-Anonymous inner class

Related Article

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.