shencang / note

关于学习的一点东西,个人笔记。系统记录见博客:
http://blog.shencangblue.com
Apache License 2.0
6 stars 1 forks source link

惹不起惹不起 #5

Open shencang opened 6 years ago

shencang commented 6 years ago

import java.util.Random;

public class HelloWorld {
    public static void main(String ... args) {
        System.out.println(randomString(-229985452)+' '+randomString(-147909649));
    }

    public static String randomString(int seed) {
        Random rand = new Random(seed);
        StringBuilder sb = new StringBuilder();
        while(true) {
            int n = rand.nextInt(27);
            if (n == 0) break;
            sb.append((char) ('`' + n));
        }
        return sb.toString();
    }
}