Answer the question
In order to leave comments, you need to log in
What does lambda want from me?
public class test{
interface Chislo {
public boolean chislo(int x);
}
public static void main(String[] args) {
final int x= 10;
Chislo a = x->{
if ((x%13) == 0) return true;
return false;
};
System.out.println(a);
}
}
Answer the question
In order to leave comments, you need to log in
In your case, the lambda did not work because you didn't call a.chislo(x)
. In general, you can do it much easier:
public static void main(String[] args) {
Predicate<Integer> isDivided13 = x -> (x%13) == 0;
Boolean result = isDivided13.test(10);
System.out.println(result);
}
x -> (x%13) == 0
test
Predicate
test
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question