Reference "Introduction to Java that can be clearly understood p133 ~ p164"
There was an ambiguous part about the arrangement, so I reviewed it with "Clearly understand".
First, in the image below, the meaning of using an array is
If you write it like this ・ It is troublesome when the number of subjects increases ・ Cannot be processed together
Inconvenience such as occurs.
Therefore, a data structure that stores a plurality of data of the same type in the order of arrangement is an "array".
** * Note that array elements start at 0. ** **
The array in the above example is
int[] score = new int[]
Can be rewritten with.
The number of elements in the array is
Array variable name.length
Can be obtained at.
It is also possible to rotate an array with a for loop or an extended for statement.
・ For loop
for(int = 0; i <Array variable name.length; i++)
・ In the case of extended for statement
for(Element type Variable name (optional):Array variable name)
I wanted to learn about the ArrayList class, but it didn't seem to be mentioned in this reference book. However, I learned a lot about the basics of arrays. I thought it was easy to understand even for beginners like me. I thought that using arrays as well as variables would make the code smarter at once.
It can be turned with two, a for loop and an extended for statement, but I can use the extended for statement. I thought it would be easier to see if I removed the loop variables and subscripts.
Next, I will write about object orientation.
Recommended Posts