<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.6.10</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk7</artifactId>
<version>1.6.10</version>
</dependency>
</dependencies>
groovy
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.6.10'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10'
}
kotlin
class Utils {
companion object {
fun getStringLength(str: String): Int {
return str.length
}
}
}
import com.example.Utils;
public class Main {
public static void main(String[] args) {
String str = "Hello, Kotlin";
int length = Utils.Companion.getStringLength(str);
System.out.println("Length of the string is: " + length);
}
}
Length of the string is: 14