首先要写个方法,能获取一个随机字符串
public static String randString(int count){
String text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random rand = new Random();
String res = "";
for(int i = 0;i<count;i++){
res+=text.charAt(rand.nextInt(text.length()));
}
return res;
}
这里是一个个列出字母和数字,然后随机从里面挑,如果要随机汉字的话,这个方法就不大好了,应该去查汉字的编码范围,然后生成这个范围的随机数。
我们写个方法,取随机数,可以限定范围的那种,因为我们等下要随便旋转一个角度
public static int randint(int a,int b){
Random r = new Random