码迷,mamicode.com
首页 > 其他好文 > 详细

生成随机姓名

时间:2019-03-13 12:12:30      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:pen   void   coding   print   value   str   byte   throws   new   

public class Demo {
  @Test
  public void test01() throws UnsupportedEncodingException{
    Random r=new Random();
    for(int i=0 ;i<100;i++){
      StringBuffer name=new StringBuffer();
      for(int j=0;j<2;j++){
        Integer a=r.nextInt(39)+176;
        Integer b=r.nextInt(93)+161;
        byte[] arr={a.byteValue(),b.byteValue()};
        name=name.append(new String(arr,"GBK"));
      }
      System.out.println(name);
    }
  }
}

生成随机姓名

标签:pen   void   coding   print   value   str   byte   throws   new   

原文地址:https://www.cnblogs.com/li19941999/p/10522010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!