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
    
  
  
    
  | // Bununla birlikte tabiki birden fazla Secondary Constructor kullanılabilir | |
| class Person(var firstName: String, var lastName:String) { | |
| var age: Int? = null | |
| var phoneNumber :String? = null | |
| constructor(firstName: String, lastName: String, age: Int): this(firstName, lastName) { | |
| this.age = if(age > 0) age else throw IllegalArgumentException("Yaş 0'dan büyük olmalıdır") | |
| } | |
| constructor(firstName: String, lastName: String, age: Int, phoneNumber: String): this(firstName, lastName, age) { | 
  
    
      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
    
  
  
    
  | // Primary Constructor ve Secondary Constructor beraber | |
| class Person(var firstName: String, var lastName: String) { | |
| var age: Int? = null | |
| constructor(firstName: String, lastName: String, age: Int): this(firstName, lastName) { | |
| this.age = if(age > 0) age else throw IllegalArgumentException("Yaş 0'dan büyük olmalıdır") | |
| } | |
| } | 
  
    
      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
    
  
  
    
  | // Secondary Consructor | |
| class Person { | |
| var firstName: String | |
| var lastName: String | |
| constructor(firstName: String, lastName: String) { | |
| this.firstName = firstName | |
| this.lastName = lastName | |
| } | |
| } | 
  
    
      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
    
  
  
    
  | // Primary Constructor | |
| class Person(var firstName: String = "Orhan", var lastName: String = "Avan"){ | |
| init { | |
| println("Selam Çukulatam") | |
| println("$firstName $lastName") | |
| } | |
| } | 
  
    
      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>) { | |
| println("Hello World") | |
| val p1 = Person("Orhan", "Avan") | |
| val p2 = Person("Orhan", "Avan", 24) | |
| val p3 = Person("Orhan", "Avan", 24, "05XX-XXX-XX-XX") | |
| } | 
  
    
      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 Person(@get:JvmName(isMale) var male: Boolean) | 
  
    
      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 Person { | |
| private Boolean male; | |
| public Person (Boolean male) { | |
| this.male = male | |
| } | |
| public Boolean isMale() { | |
| return male; | |
| } | 
  
    
      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 person = Person("John") | |
| println(person.name) // getter | |
| person.name = "Casey"// setter | 
  
    
      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 Person(val name: String) | 
NewerOlder