Java -> Kotlin
public boolean startsWithA1(String str) {
if (str == null) {
throw new IllegalArgumentException("null이 들어왔습니다");
}
return str.startsWith("A");
}
fun startsWith(str: String?) : Boolean {
return str?.startsWith("A")
?: throw java.lang.IllegalArgumentException("null이 들어왔습니다.")
}
Java -> Kotlin
public Boolean startsWithA2(String str) {
if (str == null) {
return null;
}
return str.startsWith("A");
}
fun startsWithA2(str: String?) : Boolean? {
return str?.startsWith("A")
}
Java -> Kotlin
public boolean startsWithA3(String str) {
if (str == null) {
return false;
}
return str.startsWith("A");
}
fun startsWithA3(str: String?): Boolean {
return str?.startsWith("A") ?: false
}