Complete the code to safely call a Java method that returns a platform type.
val length = javaString?.[1]Java strings use length() method, so you must call it with parentheses.
Complete the code to safely handle a platform type that might be null.
val safeString: String = javaString[1] ?: "default"
? or ?. does not assert non-null.The !! operator asserts the value is not null, throwing an exception if it is.
Fix the error in calling a Java method returning a platform type that might be null.
val length = javaString.[1]length property causes error.!! leads to nullable type.Calling length() and then asserting non-null with !! ensures safe usage.
Fill both blanks to safely check and use a platform type from Java.
if (javaString [1] null) { val length = javaString.[2]() }
Check if javaString is not null, then call length() method.
Fill all three blanks to create a safe call chain with platform types from Java.
val length = javaString[1]?.[2]()?.let { it [3] 0 } ?: -1
Assert non-null with !!, call length(), then check if length is greater than zero.
