Last active
July 29, 2019 22:38
-
-
Save cassiompf/c1802cd0c9e09b3379db069cac174c66 to your computer and use it in GitHub Desktop.
Lambda Ex-1 Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Lambda { | |
interface Num{ | |
double getValor(); | |
} | |
interface ValorNumerico{ | |
boolean teste(int n); | |
} | |
interface ValorNumerico2{ | |
boolean teste(int n, int m); | |
} | |
public static void main(String[] args) { | |
Num numero; | |
numero = () -> 333.11; | |
System.out.println(numero.getValor()); | |
Num n2 = () -> Math.random() * 1; | |
System.out.println(numero.getValor()); | |
ValorNumerico isPar = (int n) -> (n%2) == 0; | |
System.out.println(isPar.teste(89)); | |
System.out.println(isPar.teste(90)); | |
ValorNumerico2 isDiv = (x, y) -> (x%y) == 0; | |
System.out.println(isDiv.teste(10,2)); | |
System.out.println(isDiv.teste(10,3)); | |
ValorNumerico expressao1 = n -> (n%2) == 0; | |
ValorNumerico2 expressao2 = (x, y) -> { | |
int w = x+y; | |
return w > 100; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment