Complete the code to check if two strings are equal using the correct method.
val result = str1.[1](str2)
println(result)The equals method checks if two strings have the same content exactly.
Complete the code to compare two strings lexicographically and print the result.
val comparison = str1.[1](str2)
println(comparison)The compareTo method compares strings lexicographically and returns an integer.
Fix the error in the code to correctly check if two strings are equal ignoring case.
val isEqual = str1.[1](str2)
println(isEqual)The equalsIgnoreCase method compares strings ignoring letter case differences.
Fill both blanks to create a map of words to their lengths only if the length is greater than 3.
val lengths = buildMap<String, Int> {
for ([1] in words) {
if ([2] > 3) {
this[[1]] = [2]
}
}
}We use word as the key and word.length as the value. The condition checks length > 3.
Fill all three blanks to create a map of uppercase words to their lengths only if length is greater than 4.
val result = buildMap<String, Int> {
for ([3] in words) {
if ([2] > 4) {
this[[1]] = [2]
}
}
}The key is the uppercase version of the word, the value is its length, and the loop variable is word.