您的位置:首页 > 其它

生成6为随机字符串

2014-01-01 23:00 127 查看
package testPackage;

/**

* @author Meiyuanhao

* @category 定义一个空字符串

*/

public class RandomStr {

/**

* @category 生成6为随机字符串

*/

public static void RandomToStr(){

//定义一个空字符串

String result="";

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

//生成一个97~122之间的int类型的整数

int intVal = (int) (Math.random()* 26 +97);

result = result +"_"+ (char)intVal;

}

//输出随机字符

System.out.println(result);

}

public static void main(String[] args) {

RandomStr.RandomToStr();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: