with value 1 or 2 break; case 3: // Do something with value 3 break; default: // Do something with default } val viewType: Int = 1 when (viewType) { 1, 2 -> { // Do something with value 1 or 2 } 3 -> { // Do something with value 3 } else -> { // Do something with default } } Java Kotlin
value) in strings.withIndex()) { println("The element at $index is $value") } String[] strings = new String[]{"a", "b", "c"}; for (int index = 0; index < strings.length; index++) { String value = strings[index]; System.out.println("The element at " + index + " is " + value); }
ArrayList<String>() strings.add("a") strings.add("b") strings.add("c") 型態省略略 val num = 1 val str = "hello" 型態省略略 型態省略略 val str:String = "hello" val num:Int = 1
Liskov substitution • 接⼝口隔離原則 Interface segregation • 依賴反轉原則 Dependency inversion by Robert C. Martin https://ithelp.ithome.com.tw/articles/10191553 http://teddy-chen-tw.blogspot.com/2014/04/solid.html