Last active
December 5, 2016 13:15
-
-
Save mokomokohitsuzi/6503663d65c72cf3ea3bf5704be343f9 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習6-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class En06_02 { | |
public static void main(String[] args) { | |
//先頭が5なので、final変数で5を指定。 | |
final int MAX =5; | |
int[] a = new int[MAX]; | |
//for文で回しながら、結果も表示する。 | |
//配列変数.lengthで配列の長さを取得できる。 | |
for (int i = 0; i < a.length; i++) { | |
//MAXから配列のインデックス分減算する。 | |
a[i] = MAX - i; | |
System.out.println("a[" + i + "] = " + a[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment