一,Math类


public class MathDemo {

 public static void main(String args[])
 {
  System.out.println("PI="+Math.PI);
  System.out.println(Math.max(1, 2));
  //四舍五入
  System.out.println(Math.round(89.6));
 }
 
}

二,Random类

import java.util.Random;


public class RandomDemo {

 public static void main(String args[])
 {
  Random r=new Random();
  for(int i=0;i<10;i++)
  {
   System.out.println(r.nextInt(100)+"、");
  }
 }
}

posted on 2011-01-29 12:19  魔战  阅读(204)  评论(0编辑  收藏  举报