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
| val hi = "Hello World" | |
| // Çıktı: hi = Hello World | |
| println("hi = $hi") | |
| // Çıktı: Hello World.length = 11 | |
| print("$hi.length = ${hi.length}") |
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
| print(""" | |
| SELECT * | |
| FROM User | |
| WHERE Age = 42 | |
| """) | |
| /* Çıktısı: | |
| SELECT * | |
| FROM User | |
| WHERE Age = 42 |
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
| println(""" | |
| |SELECT * | |
| |FROM User | |
| |WHERE Age = 42 | |
| """.trimMargin()) | |
| /* Çıktısı: | |
| SELECT * | |
| FROM User | |
| WHERE Age = 42 |
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 displayFence(character: Char = '#', length: Int = 15) { | |
| for (i in 1..length) { | |
| print(character) | |
| } | |
| } | |
| fun main(args: Array<String>) { | |
| // character değeri pas geçilerek çağırma | |
| // Çıktısı: ##### | |
| displayFence(length = 5) |
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 square(k: Int) = k * k | |
| fun main(args: Array<String>) { | |
| // Çıktısı: 25 | |
| print(square(5)) | |
| } |
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 tekMiCiftMi(sayi: Int) : String { | |
| return when (sayi % 2) { | |
| 0 -> "Çift" | |
| 1 -> "Tek" | |
| else -> { | |
| throw IllegalArgumentException() | |
| } | |
| } | |
| } |
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 tekMiCiftMi(sayi: Int) : String { | |
| return when (sayi % 2) { | |
| 0, 1 -> "Tek veya çifttir" | |
| else -> { | |
| throw IllegalArgumentException() | |
| } | |
| } | |
| } | |
| fun main(args: Array<String>) { |
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 harfNotuHesapla(not: Int) : String { | |
| return when (not) { | |
| in 0..39 -> "FF" | |
| in 40..49 -> "FD" | |
| in 50..54 -> "DD" | |
| in 55..59 -> "DC" | |
| in 60..69 -> "CC" | |
| in 70..79 -> "CB" | |
| in 80..84 -> "BB" | |
| in 85..89 -> "BA" |
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 isString(obj: Any): String { | |
| return if (obj !is String) | |
| "String değildir" | |
| else | |
| "String'tir." | |
| } | |
| fun main(args: Array<String>) { | |
| // Çıktısı: String değildir | |
| print(isString(40)) |
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 test(x: Any): Int { | |
| if (x is String) { | |
| return x.length | |
| } else if (x is Array<*>) { | |
| return x.size | |
| } else if (x is Int) { | |
| return x | |
| } else { | |
| throw IllegalArgumentException() | |
| } |