黑马程序员——System、Runtime、Date、Calender、Math静态类
2014-03-08 08:44
246 查看
----------------------
ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------
类System
Propertise getPropertise() 获取系统属性信息
Propertise prop = System.getPropertise();
//使用map的方法取出集合中的元素,增强for循环(利用Propertis是Hashtable的子类)
//在系统中定义一些特有属性
System.setProperty("myKey","myValue");
//获取指定属性信息
String value = System.getProperty("myKey");
------------------------------------------------------------------------------------------------------
类Runtime
使应用程序与系统相关,无构造函数,自有方法返回一个对象static Runtime getRuntime
//获取Runtime对象
Runtime r = Runtime.getRuntime();
//执行本地程序
Pracess p = r.exec("c:\\program File\\QQ.exe");
//杀掉运行程序的子进程
p.destriy();
------------------------------------------------------------------------------------------------------
类Date、类Calender
//创建时间对象
Date d = new Date();
//创建模板,将模板封装到SimpleDateFormat 对象中
SimpleDateFormat sdf = new SimpleDateFormat(":yyyy年MM月dd日 E hh:mm:ss");
//调用formate方法让模板格式化Date对象
String time = sdf.formate(d);
Calendar c = Calendar.getInstance();
//获取年
String y = c.get(Calendar.YEAR);
//获取月
String M = c.get((Calendar.MONTH)+1)
//查表法获取月
String[] mons = {"一月","二月","三月","四月",.....,"十二月“}:
int index = c.get(Calendar.MONTH);
String M = mons[index];
//设置时间
c.set(2012,2,23);
//设置指定位
c.add(Calendar.MONTH,-1);
------------------------------------------------------------------------------------------------------
Math类
double
double d = 16.34;
double d1 = Math.ceil(d); //返回大于d的最小整数
double d2 = Math.floor(d); //返回小于d的最大整数
double d3 = Math.pow(2,3); //求幂
double d4 = Math.random(); //产生一个[0.0, 1.0);的随机数
int d5 = (int)d4*10; //获得一个[0,10)的随机数
//Random获得一个[0, 10)的随机数
Random r = new Randow();
int d5 = r.nextInt(10);
long l = Math.round(12.34); //四舍五入
----------------------
ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------
ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------
类System
Propertise getPropertise() 获取系统属性信息
Propertise prop = System.getPropertise();
//使用map的方法取出集合中的元素,增强for循环(利用Propertis是Hashtable的子类)
System.setProperty("myKey","myValue");
//获取指定属性信息
String value = System.getProperty("myKey");
------------------------------------------------------------------------------------------------------
类Runtime
使应用程序与系统相关,无构造函数,自有方法返回一个对象static Runtime getRuntime
//获取Runtime对象
Runtime r = Runtime.getRuntime();
//执行本地程序
Pracess p = r.exec("c:\\program File\\QQ.exe");
//杀掉运行程序的子进程
p.destriy();
------------------------------------------------------------------------------------------------------
类Date、类Calender
//创建时间对象
Date d = new Date();
//创建模板,将模板封装到SimpleDateFormat 对象中
SimpleDateFormat sdf = new SimpleDateFormat(":yyyy年MM月dd日 E hh:mm:ss");
//调用formate方法让模板格式化Date对象
String time = sdf.formate(d);
Calendar c = Calendar.getInstance();
//获取年
String y = c.get(Calendar.YEAR);
//获取月
String M = c.get((Calendar.MONTH)+1)
//查表法获取月
String[] mons = {"一月","二月","三月","四月",.....,"十二月“}:
int index = c.get(Calendar.MONTH);
String M = mons[index];
//设置时间
c.set(2012,2,23);
//设置指定位
c.add(Calendar.MONTH,-1);
------------------------------------------------------------------------------------------------------
Math类
double
double d = 16.34;
double d1 = Math.ceil(d); //返回大于d的最小整数
double d2 = Math.floor(d); //返回小于d的最大整数
double d3 = Math.pow(2,3); //求幂
double d4 = Math.random(); //产生一个[0.0, 1.0);的随机数
int d5 = (int)d4*10; //获得一个[0,10)的随机数
//Random获得一个[0, 10)的随机数
Random r = new Randow();
int d5 = r.nextInt(10);
long l = Math.round(12.34); //四舍五入
----------------------
ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------
相关文章推荐
- 黑马程序员———其他对象(System,DateFormat,Calender,Runtime,Math)
- 黑马程序员 Java基础之System,Runtime,Date,Calendar,Math.Random对象
- 黑马程序员------其他类(System、Runtime、Date、Calendar、Math-Random)
- 黑马程序员_Java其他对象(System,Runtime,Date,Calendar,Marh-Random)
- 黑马程序员_<<常用类(System.Math,Calendar,Date,Runtime)>>
- 黑马程序员_集合4(高级for,可变参数,静态导入,Date,Calendar,Math,System,RunTime)
- Lesson_for_java_day13--java的常用类—StringBuffer、基本数据类型包装类、Date、Calender、Math、Runtime、System等
- 黑马程序员--Java笔记11--静态类(Collections、Arrays、System、Runtime、Date、Calendar、Math)
- 黑马程序员--常用API(String、基本数据类型的包装类、System、Runtime、Date、Calendar、Math)
- 黑马程序员之System、Runtime、Math、Date、Calendar类
- 黑马程序员——Java基础——其他对象(System、Runtime、Date、Calendar、Math)
- 黑马程序员--Java基础--集合、泛型、其他对象(System、Runtime、Math、Date)
- 黑马程序员-day18其他对象System,Runtime,Date,Calendar,Math-Random
- 黑马程序员_JAVA- System、Runtime、Math、Date、Calendar
- 几个类System ,Runtime,Date,Calender,Math
- day20_System+Runtime+Math+Date+Calender+IO流
- 黑马程序员——第16天下——(API)System,Runtime,Date,Calendar,Math
- 黑马程序员_集合(高级for,可变参数,静态导入,Date,Calendar,Math,System,RunTime)
- 黑马程序员--------java Collections、Arrays、高级for、可变参数、静态导入、System、Runtime、Math、Date、Calendar
- 黑马程序员_JAVA学习日记_JAVA中API中数据类型包装类(Integer),System,Runtime,Date