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

来源:互联网 发布:房产系统源码 编辑:程序博客网 时间:2024/05/16 18:58

初学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;

  }

}

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

代码只是作为个人保存 

0 0