LoginSignup
0
0

More than 1 year has passed since last update.

すっきりjavaでわからなかったとこ5−13

Posted at

戻り値が配列の時

public class Main {

  public static int[] makeArray(int size) {
    //int[]で配列を作る
      int[] newArray = new int[size];
      for (int i = 0; i < newArray.length; i++ ) {
       newArray[i] = i;
      }
     return newArray;
  }

  public static void main(String[] args) {
//makeArray(3)を実行して
    int[] array = makeArray(3);
//結果を int i をarrayに変換する
    for (int i : array) {
      System.out.println(i);
    }
  }

}
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