October 2018
Intermediate to advanced
370 pages
9h 15m
English
Create a mutable list in the getMutableList function and return the list, as follows:
fun getMutableList() : MutableList<Int> { val list = mutableListOf(1,2,3,4,5) return list}
Create a listFromKotlin variable in Java and assign a list to this variable by using the CallKotlinKt.getMutableList function from Kotlin.
See the following example:
public static void main(String args[]) { System.out.print("Kotlin mutable list"); //List<int> listFromKotlin = KotlinToJavaKt.mutableList(); List<Integer> listFromKotlin = CallKotlinKt.getMutableList(); listFromKotlin.add(6); for (int i = 0; i < listFromKotlin.size(); i++) { System.out.println("Element " + listFromKotlin.get(i)); } }
Notice that Kotlin is not familiar ...
Read now
Unlock full access