懒逼版随机数

public void Stringtest2(){

List<String> string=new ArrayList<String>();

Random random=new Random();

//28

      //String[]s={"q","w","e","r","t","y","u","i","o","p","[","a","s","d","f","g","h","j","k","l",";","z","x","c","v","b","n","n","m"};

       String s="mnbvcxz431fghjkl&*%uytrewq";       

int k;

String s2=null;

for(int i=0;i<10;i++){ 

do{ k=random.nextInt(26);

s2=s.substring(k);

}while (s2.length()>10); 

string.add(i,s2);

}

 

System.out.println("-------排序前-------");

for (String string2 : string) {

  System.out.println(string2);

}

System.out.println("-------排序后-------");

Collections.sort(string);

for (String string2 : string) {

  System.out.println(string2);

}

}

自己测试了,感觉还是有点规律可循,有谁能解释下吗

慕瓜8829151
浏览 1436回答 1
1回答

wldraa

s2 = s.substring(k);这一句每次都是截取从第 k 个字条到结尾的字符串。所以所有的s2 都是 s 的最后几位

慕瓜9220888

NIZOHUBSIOQGFESYSDBRYUVMRPTZPWMCFGDKSUKJBPDHBDICKKBLPZSQFXCIZVBTUMYAAEXQMSEDLHHHLLYBPKIBIDGJJKBCLSZNSPERWKZOBSIVBLCEHKQWFRLSTKFSSSXHJGDTRNCUBYEKMDDLOVOZKIAZYAIFLFXVENPGWKEXMIREBPMGYAAMSSTDXFDWFXEFPPPHGPEFDXRTJCXDDLYSOEKZIJPAAHMLONQHEEIHGPURYPHYWXDVWQKKFNMQCQGXXZNWPERIQKCKSETHNKBNVWVOVMGMVDMBARHOPDRKJSZPGGYMIHWOYZTHVLDWLLCCIZCQYPJQQRZYHGTARBIWPYABFJJVGQKQFVQNOPVOHNYFFQQYJXDKRRBYENPMDDNWEAZIIAALLTCBVJPJKFDOQVVWWQFDDZIBOCCYOHKGQGRVXMLATJABLDLODDNAUEMKZIREVUEMBALDROYINNWWVSFCZRJLUTKUUVSAZYOLAQBIFHQMTXNOVTCEUKLSCCKZIGNNOSODVLKROEFGLKJIZGYZOSBAGWTZZBFEDTAYCDKITZWNNKOOPIRKBVLFETZSAOLICCHQVELIZZZXGFUVPWWUCRLOYVCWJ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