Last active
November 20, 2018 07:22
-
-
Save ozcanzaferayan/b105932d2542ae2192b91b33d7ccb0e5 to your computer and use it in GitHub Desktop.
Kotlin Nedir: Java SAM'li lambda ifadesi
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
class Main { | |
// Lambda fonksiyonu çağırmak için tek metod içeren Callable interface'i oluşturulur. | |
// SAM (functional interface) dediğimiz aslında bu tip interface'lerdir. | |
interface Callable<T> { T call(); } | |
public static void main(String[] args) { | |
// Callable interface'i ile bir lambda fonksiyonu oluşturulur. | |
Callable<String> strCallable = () -> "Hello world!"; | |
// call metodu ile lambda fonksiyon çağrılır | |
System.out.println(strCallable.call()); // Çıktı: Hello World | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment