In this code snippet, why does the compiler not allow the value of y to change? For(y in 1..100) y+=2

Question:In this code snippet, why does the compiler not allow the value of y to change? For(y in 1..100) y+=2

1.Y must be declared with var to be mutable

2.Y is an implicitly immutable value

3.Y can change only in a while loop

4. In order to change y, it must be declared outside of the loop


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!