Skip to content

Instantly share code, notes, and snippets.

@shikajiro
Last active December 19, 2015 22:39
Show Gist options
  • Save shikajiro/6028911 to your computer and use it in GitHub Desktop.
Save shikajiro/6028911 to your computer and use it in GitHub Desktop.
Java APIを使ってみる
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// 省略可能
// int[] numbers = {10, 21, 1, 15};
int[] numbers = new int[] { 10, 21, 1, 15 };
// 昇順に並び替える
Arrays.sort(numbers);
for (int i : numbers) {
System.out.println(i);
}
// まとめて代入する
Arrays.fill(numbers, 3);
for (int i : numbers) {
System.out.println(i);
}
// 数学系のAPI
// 3の3乗
double ans = Math.pow(3, 3);
System.out.println(ans);
// 10の平方根
ans = Math.sqrt(10);
System.out.println(ans);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment