Skip to content

Instantly share code, notes, and snippets.

@lockdef
Created May 3, 2020 14:02
Show Gist options
  • Save lockdef/92915ffc2421bcd44dce67879cce9f4d to your computer and use it in GitHub Desktop.
Save lockdef/92915ffc2421bcd44dce67879cce9f4d to your computer and use it in GitHub Desktop.
week102
package week102;
public class MyClass {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int a, b;
String str1, str2;
a = 1;
b = 2;
str1 = "Hello, ";
str2 = "World!";
System.out.printf("%d\n", a+ b);
System.out.printf("%s\n", str1 + str2);
System.out.println(str1 + str2);
System.out.println(a + str1 + b + str2);
int[] test;
test = new int[5];
test[0] = 80;
test[1] = 60;
test[2] = 22;
test[3] = 50;
test[4] = 75;
for (int i = 0; i < test.length; i++) {
System.out.println(i + ": " + test[i]);
}
int sum_num = 0;
for (int i = 0; i < test.length; i++) {
sum_num += test[i];
}
System.out.println("合計は" + sum_num);
int max_num = 0;
for (int i = 0; i < test.length; i++) {
max_num = Math.max(max_num, test[i]);
}
System.out.println("最大値は" + max_num);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment