import java.util.*;
public class test {
public static void main(String[] args) {
creating UUID
UUID uid = new UUID();
HashSet hs=new HashSet();
// checking the value of random UUID
for(int i=1;i<1000;i++){
//System.out.println("Random UUID value: "+UUID.randomUUID().toString());
Random r=new Random();
String st[]=new Integer(r.nextInt(i)).toString().split("");
String s[]=UUID.randomUUID().toString().split("-");
System.out.println(UUID.randomUUID());
System.out.println(s[1].replaceAll("[^0-9]","1"+st[0]));
hs.add(s[1].replaceAll("[^0-9]","1"+st[0]));
}
System.out.println(hs.size()+".............................");
}
}
Thursday, 3 December 2015
4 digit Random Number generation in java.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment