Math和Random类

一,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)+"、");
  }
 }
}

原文地址:https://www.cnblogs.com/jinzhengquan/p/1947420.html