5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Java】配列について

Posted at

Javaの配列について勉強したことのメモです。

###配列の宣言

(int方の場合)
int[] arr = new int[5];

###配列arrに値を代入

arr[0] = 3;         // 1番目(先頭)の要素に 3 を代入
arr[1] = 1;         // 2番目の要素に 1 を代入
arr[2] = 6;         // 3番目の要素に 6 を代入
arr[3] = 0;         // 4番目の要素に 0 を代入
arr[4] = 4;         // 5番目の要素に 4 を代入

###arrを簡略化

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

###配列arrの要素数を出力

(要素数が3の場合)
System.out.println("配列arrの要素数…" + arr.length);
結果:配列arrの要素数…3
5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?