[Java] About arrays

This is a memo of what I learned about Java arrays.

Array declaration

(For int)
int[] arr = new int[5];

Assign a value to the array arr

arr[0] = 3;         //Substitute 3 for the first (first) element
arr[1] = 1;         //Substitute 1 for the second element
arr[2] = 6;         //Substitute 6 for the third element
arr[3] = 0;         //Substitute 0 for the 4th element
arr[4] = 4;         //Substitute 4 for the 5th element

Simplify arr

int[] arr = {3, 1, 6, 0, 4};

Output the number of elements in the array arr

(When the number of elements is 3)
System.out.println("Number of elements in array arr ..." + arr.length);
result:Number of elements in array arr ... 3

Recommended Posts

[Java] About arrays
About Java arrays
Java, about 2D arrays
About Java interface
[Java] About Java 12 features
Something about java
Where about java
About Java features
About Ruby arrays
About Java threads
[Java] About interface
About Java class
About java inheritance
About interface, java interface
About List [Java]
About java var
About Java literals
About Java commands
About class division (Java)
Combine arrays in Java
About [Java] [StreamAPI] allMatch ()
About Java StringBuilder class
[Java] About Singleton Class
About Java method binding
[Java] About anonymous classes
About method splitting (Java)
[Java Silver] About initialization
About Java Array List
About Java Polymorphism super ()
About inheritance (Java Silver)
About Java String class
About Java access modifiers
About Java lambda expressions
About Java entry points
About Java 10 Docker support
Personal summary about Java
[Java] About enum type
All about Java programming
About java abstract class
A note about Java GC
What I researched about Java 8
Study java arrays, lists, maps
What I researched about Java 6
[Gradle] About Java plug-in tasks
About Java variable declaration statements
What I researched about Java 9
[Java] About try-catch exception handling
About Java class loader types
[Java Silver] About equals method
[Java] About String and StringBuilder
What I researched about Java 7
About =
About Alibaba Java Coding Guidelines
About Java class variables class methods
About Java Packages and imports
About abstract classes in java
[Android / Java] Learned about DataBinding
What I researched about Java 5
About Java static and non-static methods