1
Because in Java it’s called method and in Kotlin it’s called function, it’s just a different nomenclature, or is there a significant difference?
Java:
public class Teste {
public static void main(String[] args) {
int result = multiplicaDois(2);
System.out.print(result);
}
public static int multiplicaDois(int x) {
return 2 * x;
}
}
Kotlin:
fun main(args: Array<String>) {
val result = multiplicaDois(2);
println(result);
}
fun multiplicaDois(x: Int): Int {
return 2 * x;
}
Related: https://answall.com/q/11848/57801
– Don't Panic
Basically there is no difference, in the past this difference in theory existed. The default is that the functions that exist within a class have the method name, because they are methods that are executed by the class. It’s more like defining languages that use object orientation.
– Chiodini