This file contains hidden or 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
| fun main(args: Array<String>) { | |
| // SAM kullanmadan inline bir şekilde fonksiyon tipi oluşturulabiliyor | |
| val helloWorld = { x: String, y: String -> x + y } | |
| print(helloWorld("Hello", " World")) // Çıktı: Hello World | |
| } |
This file contains hidden or 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 interface Appendable { | |
| /* | |
| * Appendable sınıfından türeyen ve append metodunu kullanan her sınıf | |
| * checked exceptions'tan dolayı IOException fırlatmak veya handle etmek zorundadır. | |
| */ | |
| Appendable append(CharSequence csq) throws IOException; | |
| } |
This file contains hidden or 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
| try { | |
| logfile.append("Hello World") | |
| } | |
| catch (IOException e) { | |
| // Bir şey yapma | |
| } |
This file contains hidden or 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
| data class User(var name: String, var age: Int) |
This file contains hidden or 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
| package com.example.ozcanzaferayan.testkotlin; | |
| import kotlin.Metadata; | |
| import kotlin.jvm.internal.Intrinsics; | |
| import org.jetbrains.annotations.NotNull; | |
| import org.jetbrains.annotations.Nullable; | |
| @Metadata( | |
| mv = {1, 1, 11}, | |
| bv = {1, 0, 2}, |
This file contains hidden or 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 { | |
| public static void main(String[] args) { | |
| System.out.println("Hello world!"); | |
| } | |
| } |
This file contains hidden or 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
| var str = "Hello World" | |
| fun main(args: Array<String>) { | |
| print(str) | |
| } |
This file contains hidden or 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
| // Örnek basit fonksiyon | |
| fun hello(): String { | |
| return "Hello World" | |
| } | |
| /* | |
| * hello fonksiyonunun geri dönüş değeri runtime'da hesaplandığı için | |
| * const bir ifadeye fonksiyon geri dönüş değeri atandığında hata verir. | |
| */ | |
| const val hello = hello() // Hata: Const 'val' initializer should be a constant value |
This file contains hidden or 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
| // User data class'ının oluşturulması | |
| data class User(var name: String, var age: Int) | |
| fun main(args: Array<String>) { | |
| // Aynı değerlere sahip iki User nesnesinin oluşturulması | |
| val val1 = User("zafer", 42) | |
| val val2 = User("zafer", 42) | |
| if(val1 == val2) | |
| print("eşittir") |
This file contains hidden or 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 User { | |
| var name: String | |
| var age: Int | |
| constructor(name: String, age: Int){ | |
| this.age = age | |
| this.name = name | |
| } | |
| } |