生成随机六个字母

 

 1 package com.yhqtv.demo02.ThreadPool;
 2 
 3 //生成随机六个字母
 4 
 5 public class Test {
 6     public static void main(String[] args) {
 7         String result = "";//定义空字符串
 8         for (int i = 0; i < 6; i++) {
 9             int intValue = (int) (Math.random() * 26 + 97);//把double强转int
10             result = result + (char) intValue;//把int数值强转char字符,通过空字符串拼接六个字母
11         }
12         System.out.println(result);
13     }
14 }

 

 

posted @ 2020-04-22 09:54  鑫淼  阅读(493)  评论(0)    收藏  举报