Hello friends today we will see how to initialize array in Kotlin.
1. Lets have a String array.
2. Lets have int array
1. Lets have a String array.
//In Java
String[] mLabel={"One","Two","Three","Four","Five"}// In Kotlin
var mLabel = arrayOf<String>("One", "Two", "Three", "Four", "Five")
2. Lets have int array
// In Java3. Create array of size and initialize with value lambda
int[] numbers = {1,2,3,4,5}// In Kotlin
val numbers : IntArray = intArrayOf(1,2,3,4,5)
val nu : IntArray =kotlin.IntArray(5)
val num : IntArray = kotlin.IntArray(5,{i->1})Create int array of size 5 and initializes with 1
No comments:
Post a Comment