Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
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 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개발용

Random 본문

개발/JAVA

Random

DeP 2016. 11. 10. 11:41

java.util.Random;

 

Random rd = new Random(Seed);    //Seed값 입력 안하면 내부에서 setSeed(System.currentTimeMillis()); 호출

rd.nextInt(bound);    //0~bound-1 까지의 랜덤 값

 

Math.random() : 0이상 1미만의 랜덤 값

ex) 5~10까지 : Math.round(Math.random()*5)+5;

 

'개발 > JAVA' 카테고리의 다른 글

예외처리 Exception  (0) 2016.11.10
Interface, Abstract, 추상 클래스, 추상 메소드  (0) 2016.11.10
inner class  (0) 2016.11.10
static 멤버  (0) 2016.11.10
Array : 기본형과 객체 차이  (0) 2016.11.10