2017年6月29日 上午8:02
1.
Object
Java.lang.Object
1. equal()
2. toString()
3. getClass() 返回运行时类
4. finalize()
5. notify() 唤醒在此对象监视上等待的单个线程
6. notifyAll()
7. wait()
Math
java.util.Math
都是静态方法
1. abs()
2. max()
3. min()
4. random() 0.0~1.0 包括0.0 不包括1.0
5. sin()
6. exp()
7. sqart(9) = 3
8. Pow(2.3) = 8
Date
1. 日期转字符串1(DateFormat.getDateInstance)1 | Date date = new Date(); |
2. 日期转字符串2(SimpleDateFormat)1 | //日期转换成字符串 |
Calendar//默认指向的是当前时间,站在当前日期的角度
操作的步骤一般是1-4
1. 获取对象
Calendar.getInstance()
2. 修改默认时间
1. cal.add()
2. cal.set(年,月,日)
1. 月是0-11
3. 对当前设置的时间进行转换
1. cal.get(Calendar.DAY_OF_WEEK)
1. 星期日=1
2. 获取当前设置日期的星期几
4. 得到Date类型的时间
1. cal.getTime()
1 | //获取操作对象 |
包装类
- 八个基本类型对应一个包装类
- 数字和字符之间的转换
- Integer.parseInt(str)
1
2
3
4String str="123";
int num1 = Integer.parseInt(str);
double num2 = Double.parseDouble(str);
Sysytem.out.print(num1 + num2); - String.valueOf(num1)
1
2String str = num1 + "";
String str = String.valueOf(num1);
- Integer.parseInt(str)
- 装箱 拆箱
1
2
3
4
5Integer integer = new Integer(20); //手动装箱
Integer integer = 20;//自动装箱
int i = new Integer(5).intValue();//手动拆箱
int i = new Integer(5);//自动拆箱 - Integer 不能自动转换为 Float
1
2
3
4
5
6public static void main(String args[]){
method(5);//这里要改成method(5f)
}
public static void method(Float f){
System.out.println(f);
}