관리 메뉴

nalaolla

Random 객체 본문

JAVA/21. Random

Random 객체

날아올라↗↗ 2015. 12. 1. 21:57
728x90
  1. package test.com;
  2.  
  3. import java.util.Random;
  4.  
  5. public class Test01Random {
  6.  
  7.     public static void main(String[] args) {
  8.         System.out.println("Random...");
  9.        
  10.         System.out.println(Math.random());   //난수발생
  11.        
  12.         Random ran = new Random();
  13.         System.out.println(ran.nextInt(45+1));
  14.         System.out.println(ran.nextDouble());
  15.         System.out.println(ran.nextBoolean());
  16.  
  17.     }
  18.  
  19. }

============================================

랜덤객체는 Math.random과 Random클래스 두개가 존재한다..


728x90