The HomeWork has three components:
-
Null safety.
-
Strings.
-
Numbers.
Note: You must save your solution as
solution.ktto be submitted before 9AM.
In the code below, add an if statement to the beginning of getLength that
returns zero if str is null:
fun getLength(str: String?) : Int {
// Add null check here
return str.length;
}
fun main(args: Array<String>) {
println(getLength('This is a string!'))
}
old = The quick brown fox jumps over the lazy dog.
new = brown fox jumps.
C = (5 (F-32)) / 9.
212.0 degree Fahrenheit is equal to 100.0 in Celsius.