Random 클래스

DevTool/Java 2009. 6. 8. 17:52

package ch08;

import java.util.*;

public class Ch0811
{
 public static void main(String[] args)
 {
  //Random : 일명 주사위와 같은 형태로 난수를 발생시키는
  //메서드를 가지고 있는 클래스.
  Random a  = new Random();
  //nextInt()는 정수형의 범위내에서 임의의 난수를
  //정수로 변환하는 메서드임.
  int result = a.nextInt();
  System.out.println("result : "+result);
  result = a.nextInt(6);
  System.out.println("주사위 : "+result);
 }

}

Posted by 말없제이
,