5
7

More than 5 years have passed since last update.

配列の宣言・確保・代入の方法4つ

Last updated at Posted at 2014-05-02

・宣言と確保の部屋は統一する

・javaだとインデントは必ず0から始まる

    //宣言、確保、代入
    int[] ten; //宣言
    ten = new int[3]; //確保
    ten[0] = 65;
    ten[1] = 90;
    ten[2] = 75;
    //宣言と確保をして、代入
    int[] ten = new int[3];
    ten[0] = 63;
    ten[1] = 90;
    ten[2] = 75;
    //配列の初期化
    //java{}と宣言は同時にしないといけない
    int[] ten = {63, 90,75};
    //宣言をして、まとめて代入
    int[] ten;
    ten = new int[]{63,90,75};
5
7
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
7