Android Code Snippet Using Java 8+ lambdas with inline Java code

1. Download attached library and put in additional libraries folder.
2. Add to main module:
B4X:
#AdditionalJar: core-lambda-stubs.jar, ReferenceOnly


Example:
B4X:
'in B4XPage
#if java
import java.util.*;
public void test() {
 List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);
    numbers.forEach( (n) -> BA.Log("" + n) );
}
#End If

B4X:
Me.as(JavaObject).RunMethod("test", Null)
 

Attachments

  • core-lambda-stubs.jar
    17.7 KB · Views: 129

Daestrum

Expert
Licensed User
Longtime User
Is it
B4X:
Me.As(JavaObject). ...

or
B4X:
(Me).As(JavaObject). ...

As 'Me' doesn't appear to have .As as a method.

After-thought: it could be in the jar I forgot to add :)
 
Top