Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun main() {
- val charDizi = mutableListOf('K', 'O', 'T', 'L', 'I', 'N')
- val integerDizi = mutableListOf(1, 2, 3, 4, 5, 6)
- val stringDizi = mutableListOf("Kotlin", "Java", "Python", "Ruby")
- val ogrenciDizi = mutableListOf(Ogrenci2("Serkan"), Ogrenci("Mahmut"), Ogrenci("Kamuran"))
- yazdir(charDizi)
- println("\n")
- yazdir(integerDizi)
- println("\n")
- yazdir(stringDizi)
- println("\n")
- yazdir(ogrenciDizi)
- }
- // Generic olduğunu belirtmek için fun önüne yaz
- // Aksi halde generic değil sınıf ismi olarak algılar
- fun <E> yazdir(dizi: MutableList<E>) {
- for (e in dizi) {
- println(e)
- }
- }
- class Ogrenci2(private val isim: String) {
- override fun toString(): String {
- return "Öğrenci ismi: $isim"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement