Last active
December 19, 2015 22:39
-
-
Save shikajiro/6028911 to your computer and use it in GitHub Desktop.
Java APIを使ってみる
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
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