I want to generate a random unique String and put in hashtable. I did like below code but it is not unique and it is just One Character .
while(k<4){
for(int j=1 ; j<=13 ;j++){
Hashtable<Integer, String> Deck = new Hashtable();
int myChar = (int) (Math.random()*str.length());
StringBuilder sb = new StringBuilder();
sb.append(str.charAt(myChar));
int i = (int) (Math.random() *52) ;
Deck.put(i, sb.toString());
System.out.print(Deck);
}
System.out.println();
k++;
}
output is this
{30=d}{9=e}{11=b}{10=d}{43=g}....
I want to be
{30=dea}{9=egt}{11=brf}{10=dgrtg}{43=grrh}{14=gwrt}.....
Aucun commentaire:
Enregistrer un commentaire