Did you notice, in the previous section, that the type of the variable was not included when it was initialized? This is different to Java where the type of the variable must usually accompany its declaration. From Java 11 onward, local variables can also omit the type, but fields must always be annotated with the type.
Even though Kotlin is a strongly typed language, we don't always need to declare types explicitly. The compiler attempts to figure out the type of an expression from the information included in the expression. A simple val variable is an easy case for the compiler because the type is clear from the right-hand side. This mechanism is called type inference. This reduces boilerplate code, whilst keeping the type safety we expect of a modern language.
Values and variables are not the only places where type inference can be used. It can also be used...