生成随机六个字母
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 }

个人官网yhqtv.com

浙公网安备 33010602011771号