I'm just learning Java, and I've developed apps in Objective-C before. I like the concept of "blocks", because they allow code to be ran after something happens.
For example, to execute a block after a certain amount of time in a SpriteKit app that calls a method helloWorld
from scene myScene
:
[myScene runAction:[SKAction sequence:@[[SKAction waitForDuration:5], [SKAction runBlock:^{
[myScene helloWorld];
}]]]];
Is there anything like a block in Java? If so, how would I use it? What's the syntax to...
- use it as a function parameter?
- call said block in the function?
- assign a value to the block?
I've heard a little bit about "closures," but I'm not so sure what they are or how to use them.