jbanana: Badly drawn banana (Default)
[personal profile] jbanana
Traditional: EventQueue.invokeLater(new Runnable(){@Override public void run(){doThings();}});
Hmm - lots of syntax to get those things done later.

Lambda style: EventQueue.invokeLater(()->doThings());
Nicer (but identical).

When you make a lambda in Java, it's an anonymous instance of some interface. But how does it know which interface? It matters, because the lambda has to have the right params, and it has to implement the right method (even though you didn't say what the method was).

Duh, stupid! The compiler figures it out from the context. "I need a Runnable here, so that's what this lambda must be." And now I'm not thinking "How can this possibly work?"

Edit: usual excellent stuff on the basics of this from Jenkov
From:
Anonymous (will be screened)
OpenID (will be screened if not validated)
Identity URL: 
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org


 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

September 2017

M T W T F S S
    12 3
45 678910
1112 1314151617
18192021222324
252627282930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 19th, 2017 08:48 pm
Powered by Dreamwidth Studios