public JavaHuman(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public void sayHello(String otherPersonName){ System.out.println("Hi, nice to see you "+otherPersonName); } public void sayHello(){ sayHello(""); } } class KotlinHuman(var name: String, var age: Int) { fun sayHello(otherPersonName: String = "") { println("Hi, nice to see you $otherPersonName") } } 24
{ var cityAddress = “Munich" get() = "City $field" set(city) { if (city.length < 3) throw IllegalArgumentException("City less than 3 chars") field = city } fun sayHello(otherPersonName: String = "") { println("Hi, nice to see you $otherPersonName") } } Malte Bucksch 31
{ password.isEmpty() -> "Bitte gib ein Passwort ein" password.length < 5 -> "Passwort ist nicht lang genug" !password.containsNumber() -> "Passwort muss eine Ziffer enthalten" else -> "Das Passwort ist valide" } } Malte Bucksch 60