[21.03.08~] JAVA/자바 개인적 정리
Random 클래스 (난수 만들어주는 클래스)
습관그뤠잇
2021. 3. 20. 16:58
최근 버전 들어서 생긴 임의의 난수 찾는 클래스가 따로 있음!
public class Ex01_02 {
public static void main(String[] args) {
//랜덤 클래스
//0 <= int nextInt(bound) < bound
Random rnd = new Random();
//rnd.nextInt();
for (int i = 0; i < 10; i++) {
System.out.println(rnd.nextInt(45)+1);
//lottos[j] = (int)(Math.random()*45+1);
//이렇게 직접 만들던 것을 기존 클래스 활용해서~!
} //1~45정수
}
}