首页 > 编程 > Java > 正文

java 不完整的四位随机生成验证码

2019-11-08 03:12:36
字体:
来源:转载
供稿:网友

初学java  写的东西不完整 如有错误希望大神指正

 ***************************************************

public class Random {

  public static void main(String[] args) {      for(int i=0;i<4;i++) { System.out.PRint(Key());     }      }    public static int getNumber() { return (int)(Math.random()*9);  }  public static char getLow() { return (char)((int)(Math.random()*26)+97);  }  public static char getBig() { return (char)((int)(Math.random()*26)+65);  }  public static int getNum() { return (int)(Math.random()*3);  }  public static String Key() { int k=getNum();  String sum=""; if(k==1) sum= sum+getLow(); if(k==2)  sum= sum+getBig();  if(k==0) sum= sum+getNumber();return sum;  }

}

***********************************************

代码只是作为个人保存 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表