源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

java随机字符补充版

  • 时间:2022-07-21 02:49 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:java随机字符补充版
[u]复制代码[/u] 代码如下:
public static void main(String[] args) {            //String s = RandomNum.getRandomNumStr(5);         //System.out.println(s);         System.out.println("生成5个含有5个字符的字符串:");         RandomNum.SuiJiZiFuChuan(5,5);         System.out.println("生成3个含有6个字符的字符串:");         RandomNum.SuiJiZiFuChuan(6,3);         System.out.println("生成任意1到20个含有任意1到10个字符的字符串:");         RandomNum.SuiJiZiFuChuan((int)(20*Math.random()),(int)(10*Math.random()));         System.out.println("随机性生成字符:");         int i=0;         while(i<(int)(10*Math.random())){             RandomNum.SuiJiZiFuChuan((int)(20*Math.random()),1);             i++;         }     }        public static void SuiJiZiFuChuan(int x,int y){         for(int j=0;j<y;j++){             for(int i=0;i<x;i++){                 int a=(int)(100*Math.random()+100*Math.random());                 while(true){                     if(a>96&a<123)                         break;                     else                         a=(int)(100*Math.random()+100*Math.random());                 }                 System.out.print((char)a);             }             System.out.println();         }     }
执行结果: [img]http://files.jb51.net/file_images/article/201401/20140119001651.gif[/img]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部