黑马程序员技术交流社区
标题:
分享一下 我的学习经历
[打印本页]
作者:
航航啊
时间:
2019-7-24 14:59
标题:
分享一下 我的学习经历
在刚进入就业班的这几天里,我学习到了Java的三大基本特征,封装,继承,多态.继承的格式:
public class 子类 extends 父类
多态的概念:
同一段代码不同时刻表现出不同的执行状态
多态中的向上转型和向下转型:向上转型:父类得类名 父类引用=new 子类得对象(); 自动类型转换向下转型:子类得类名 子类得引用=(子类得类名)父类引用;强制类型转换
同时还学习了抽象类和接口也学习了各种API类 Date 等等最后学习了异常
public class
ExceptionDemo03 {
public static void
main
(String[] args) {
System.
out
.println(
"开始"
)
;
// method();
try
{
method2
()
;
}
catch
(ParseException e) {
e.printStackTrace()
;
}
System.
out
.println(
"结束"
)
;
}
public static void
method
() {
try
{
int
[] arr = {
1
,
2
,
3
}
;
System.
out
.println(arr[
3
])
;
}
catch
(ArrayIndexOutOfBoundsException e){
e.printStackTrace()
;
}
}
public static void
method2
()
throws
ParseException {
String s =
"2019-7-24"
;
SimpleDateFormat sdf =
new
SimpleDateFormat()
;
Date d = sdf.parse(s)
;
System.
out
.println(d)
;
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2