其他对象知识点总结(System,Runtime,Date,Calendar,Math)

 其他对象知识点总结


 * 1.System
 * System:类中的方法和属性都是静态的。描述系统一些信息。
 * out:标准输出,默认是控制台;in:标准输入,默认是键盘。
 * 获取系统属性信息:Properties getProperties();

 * 2.Runtime
 * 该类使用了单例设计模式。
 * 该方式是static Runtime getRuntime();

 * 3.Date
 * 常用demo:
 * Date d = new Date();
 * //将模式封装到SimpleDateFormat对象中
 * SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日  E hh:mm:ss");
 * String time = sdf.format(d);//调用format方法让模式格式化指定Date对象

 * 4.Calendar
 * 常用方法:
 * (1)getInstance():获取日历
 * (2)void set(int year,int month,int date):设置时间                                          
 * (3)void add(int field,int amount):改变时间
                         
 * 5.Math
 * (1)double ceil(double a)  :返回大于指定数据的最小整数;
 * (2)double floor(double a):返回小于指定数据的最大整数;
 * (3)long round(double a) :四舍五入;
 * (4)double pow(double a,double b):指数幂;
 * (5)double random?():随机数
 * 两种写法:
 * 写法一:Random r = new Random();
 *         int d = r.nextInt(10);

 * 写法二:int d = (int)Math.random();

                     



猜你喜欢

转载自blog.csdn.net/smiling_chang/article/details/80993826