黑马程序员技术交流社区
标题:
[石家庄校区] 心路历程
[打印本页]
作者:
真的不会起网名
时间:
2019-7-7 10:06
标题:
[石家庄校区] 心路历程
课程总结
封装数据类型:
byte short int long float double char boolean
Byte Short Integer Long Float Double Character Boolean
如何通过Integer对象描述一个int型值
new Integer("")
valueof()
int与String互换
int到string:
int i=5 string s=i+"";
String.valueof()
String到int:
Integer.valueof("5") i.intvalue()
Integer.parseInt("5")
自动拆箱装箱
拆箱:Integer i=Integer.valueOf(5); int ii=i
装箱:int i=5; Integer ii=i;
Date类实例化
new Date()
Date类常用方法
getTime():获取系统时间毫秒数
setTime():根据毫秒数设置时间
SimpleDateFormat格式化日期
格式:yyyy MM dd HH mm ss
格式化:format()
解析:parse()
Calendar类用法
获取:Calendar.getInstance()
get()
根据日历字段,对指定日期进行加减:add(Calendar.YEAR,5)
set(2017,05,05)
异常
概念:不正常的现象
异常的体系结构
Throwable
Error:不可处理的异常
Exception:可处理的异常
RuntimeException: 运行时异常
非RuntimeException:编译时异常
try:异常监视块
catch():捕获块
Throwable成员方法
getMessage() 异常字符串
toString()简短异常消息
printStackTrace():详细异常消息
运行时异常和编译时异常
运行时异常:无需显示处理
编译时异常:必须显示处理
throws
概念:回避异常
自定义异常
步骤
自定义一个类继承自Exception
构造方法-> super(message)
throw
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2