java (array)

Array work procedure

int[] scores;           //①
scores = new int[5];    //②

[5] = 0,1,2,3,4 Counting from zero contents [5]

① and ② at the same time

int[] scores = new int[5];    //①②

Array creation abbreviation

int[] scores1 = new int[] {10, 20, 30, 40, 50};   
int[] scores2 = {10, 20, 30, 40, 50};   

Same meaning up and down

Turn the array in a for loop

int[] scores = {10, 20, 30, 40, 50}; 
for (int i = 0; i < scores.length; i++) {
  System.out.println(scores[i]);

Loop variable name can be specified arbitrarily

Turn an array with an extended for statement

int[] scores = {10, 20, 30, 40, 50}; 
for (int value : scores) {
  System.out.println(value);

There is no need to write loop variables and array subscripts in the above for statement`

length How to use

** Array length ** ** String length () **

Recommended Posts

[Java] array
Java array
Java array
java (array)
Java array
[Java] Array
Java array
java array
[Java] Array
java array variable
[Java] Array notes
Array
About Java Array List
Java
[Java ~ Array ~] Study memo 4
Java
Array
Java Development Basics ~ Exercise (Array) ~
[Java] Convert ArrayList to array
[Java Silver] Array generation method
How to initialize Java array
[Beginner] Java basic "array" description
Java learning (0)
Studying Java ―― 3
Java protected
[Java] Annotation
[Java] Module
[Ruby] Array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Array practice
Java methods
Java method
java (constructor)
java (override)
java (method)
Java Day 2018
Java string
Java learning memo (creating an array)
Java static
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Studying Java ―― 1
[Java] Polymorphism
Studying Java # 0
Java review
java framework
Java features
[Java] Inheritance
FastScanner Java