0
How to initialize arrays in java?
I remember in c++ you could initialize arrays using two for statements, one for index and the other one for the value. How is it like in Java?
4 Answers
+ 8
Example code with for loop:
https://code.sololearn.com/cyxO8n8zR2MG/#java
+ 8
Refer to this lesson on Array:
https://www.sololearn.com/learn/Java/2148/
0
I already saw the lesson. I want to know how to initialize array values in a specific sequence, like assigning 0 to 10 using for, while or some other statement.
0
well you can declare an array with curly brace and put all the index values inside the curly brace. Like:
int[] data = {10,20,30,40,50,60,71,80,90,91}; but the efficient way is to declare the index range and then put in the values using a loop dynamically.