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
try { | |
logfile.append("Hello World") | |
} | |
catch (IOException e) { | |
// Bir şey yapma | |
} |
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
data class User(var name: String, var age: Int) |
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
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 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 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 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 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 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 | |
} | |
} |
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
val hi = "Hello World" | |
// Çıktı: hi = Hello World | |
println("hi = $hi") | |
// Çıktı: Hello World.length = 11 | |
print("$hi.length = ${hi.length}") |
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
print(""" | |
SELECT * | |
FROM User | |
WHERE Age = 42 | |
""") | |
/* Çıktısı: | |
SELECT * | |
FROM User | |
WHERE Age = 42 |