LoginSignup
0
0

More than 3 years have passed since last update.

[Java]配列

Posted at

配列の定義

データ型[] 配列名 = {};


String[] names = {"tanaka" , "sato" , "suzuki"};
System.out.println(names[0]);

配列のfor文

配列の中身を全部出力する。

通常のfor文


String[] names = {"tanaka" , "sato" , "suzuki"};

for(int i = 0; i < names.length; i++) {
  System.out.println(names[i]);
}

拡張for文
for(データ型 変数:配列名){}


String[] names = {"tanaka" , "sato" , "suzuki"};

for(String name:names) {
  System.out.println(name);
}
0
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
0
0