2014-04-09 1 views
1

collections.shuffle에서 우리는 매번 랜덤 화가 다른지 확인하기 위해 System.namoTime()으로 전달한 임의의 seed를 인수로 지정할 수 있습니다.collections.shuffle의 무작위성의 기본 소스

이 API의 임의성의 기본 출처는 무엇입니까? (staticr에 할당 된 이전 Random이없는 경우) shuffle 메서드를 호출 할 때

+1

가능한 복제본 : [Java에서 ArrayList를 섞는 시드 설정] (http://stackoverflow.com/questions/6284589/setting-a-seed-to-shuffle-arraylist-in-java) – Gladhus

답변

2

그것은 새로운 Random 생성 : 당신은 코드 here로 올립니다 수

private static Random r; 

public static void shuffle(List<?> list) { 

     if (r == null) { 
      r = new Random(); 
     } 
     shuffle(list, r); 
    } 

.

관련 문제