You have created an array to hold three strings. When you run the code bellow, the compiler displays an error. Why does the code fail? val names = arrayOf(3) names[3]= "Delta"

Question:You have created an array to hold three strings. When you run the code bellow, the compiler displays an error. Why does the code fail? val names = arrayOf(3) names[3]= "Delta"

1.Arrays use zero-based indexes. The value 3 is outside of the array's bounds

2.You accessed the element with an index but should have used.set(

3.You declared the array with val but should have used var

4.You cannot changes the value of an element of an array. You should have used a mutable list.


Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!