Skip to content

Instantly share code, notes, and snippets.

@shikajiro
Created July 22, 2013 04:14
Show Gist options
  • Save shikajiro/6051250 to your computer and use it in GitHub Desktop.
Save shikajiro/6051250 to your computer and use it in GitHub Desktop.
for文で初期化
public class Homework {
public static void main(String[] args) {
int[] array = new int[30];
for (int i = 0; i < 30; i++) {
array[i] = i + 1;
}
int total = 0;
for (int i = 0; i < array.length; i++) {
total += array[i];
}
System.out.println("合計は" + total + "です");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment