Skip to content

Instantly share code, notes, and snippets.

@ozcanzaferayan
Last active November 20, 2018 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozcanzaferayan/b105932d2542ae2192b91b33d7ccb0e5 to your computer and use it in GitHub Desktop.
Save ozcanzaferayan/b105932d2542ae2192b91b33d7ccb0e5 to your computer and use it in GitHub Desktop.
Kotlin Nedir: Java SAM'li lambda ifadesi
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