Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- profile
- find
- tomcat
- Windows 10
- Quartz
- IntelliJ
- import
- Source
- netsh
- 줄바꿈 문자
- web.xml
- lsof
- context
- bash
- Mac
- GIT
- 네트워크
- 단축키
- VirtualBox
- maVen
- Eclipse
- Windows
- plugin
- xargs
- resource
- grep
- JavaScript
- vscode
- ssh
- port
Archives
- Today
- Total
develog
[java] random, shuffle 본문
public static int randomBetween(int start, int end) {
return (int) ((Math.random() * (end - start + 1)) + start);
}
public static <T> T randomOneOf(T[] list) {
return list[randomBetween(0, list.length - 1)];
}
public static void shuffle(Integer[] list) {
for (int i = 0; i < list.length; i++) {
int x = randomBetween(0, list.length - 1);
int y = randomBetween(0, list.length - 1);
int temp = list[x];
list[x] = list[y];
list[y] = temp;
}
}
Comments