Java(Math、Random, System,Date)
1799 ワード
Math
Random
System
Date
System.out.println(Math.PI);
System.out.println(Math.abs(-10));
// , double
System.out.println(Math.ceil(12.3));
// , double
System.out.println(Math.floor(12.3));
//
System.out.println(Math.max(10, 30));
// ,2.0^3.0
System.out.println(Math.pow(2, 3));
// 0.0-1.0 , 0.0
System.out.println(Math.random());
//
System.out.println(Math.round(12.3f));
//
System.out.println(Math.sqrt(3));
Random
//1-100
Random random = new Random(100);
System.out.println(random.nextInt());
System
//
System.gc();
//1970.1.1
long start = System.currentTimeMillis();
//
System.exit(0);
int[] src = {11,2,33,12};
int[] dest = new int[8];
// dest
System.arraycopy(src, 0, dest, 0, src.length);
Date
// 1970.1.1
Date d1 = new Date(0);
System.out.println(d1.getTime());
DateFormat df1 = DateFormat.getDateInstance();
//
SimpleDateFormat sdf = new SimpleDateFormat("yyyy mm dd hh:mm:ss");
System.out.println(sdf.format(d1));
//
String str = "1993 10 3 01:02:03";
try {
Date date = sdf.parse(str);
System.out.println(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}