Functional Programming (functional programming)

Source: Internet
Author: User

As mentioned in the previous article, callback is actually a more fundamental concept in functional programming. Now let's take a look at how functional programming is implemented in Java.

First, let's take a look at a piece of code that is familiar to Java:

// Interface class, which should be regarded as a part of functional programming. Public interface actionlistener {public void actionreceivmed (actionevent E);} class xlistener implements actionlistener {public void actionreceivmed (actionevent e) {// action here} xlistener L = new xlistener (); iexit. addactionlistener (L );

But in fact, this implementation method is redundant. In fact, it can be implemented using anonymous classes. In Java, the anonymous class is the idea of functional programming. Let's take a look.

Iexit. addactionlistener (New actionlistener () {public void actionreceivmed (actionevent e) {// action here }});

In JavaScript, the following method is available:

$ ("# Element "). click (function () {// do something}); $ ("Div. type "). each (function (INDEX) {// do something else with the index });

Reprinted from: http://www.iteye.com/topic/539515

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.