jeudi 29 décembre 2016

List of Static Methods on Class shows Lambdas using reflection

public class StaticMethodList {
    public static void main(String[] args) {
        listStaticMethods();
    }

    private static void print1To10() {
        IntStream.range(1, 11).forEach(System.out::println);
    }

    private static void listStaticMethods() {
        Stream<Method> staticMethods = Arrays.<Method>asList(StaticMethodList.class.getDeclaredMethods()).stream();
        staticMethods
                .filter(method -> !("listStaticMethods".equals(method.getName())))
                .forEach(m -> {
                    System.out.println(m.getName());
                 });

    }
}

The above code produces following output

main
print1To10
lambda$0
lambda$1

I am not sure why the lambda$ is being considered as static method. Also is there any way to obtain more details about the lambda here?





Aucun commentaire:

Enregistrer un commentaire