超越自我

一切皆有可能

 

java的一些基本容易混淆的概念

1.String str=new String("helloWorld")和String str="helloWorld"的区别
String str="helloWorld"是把"helloWorld"(地址)引用给str;
String str=new String("helloWorld")是新建"helloWorld"的对象,再将这个对象引用给str.
在我看来是"helloWorld"的地址由于String str=new String("helloWorld")而重新分配了.这样对性能很不好.

2.Math.round(11.5)和 Math.round(-11.5)的结果是多少
System.out.println("Round="+Math.round(11.5));//12
System.out.println("Round="+Math.round(-11.5));//-11

--------------------------->
-11.5     0   11.5
就是我学习的约等于,四舍五入

3.short的运算符
short s1 = 1; s1 = s1 + 1
是错误的,可以改成:short s1 = 1; s1 =(short)( s1 + 1);
也可以是short s1 = 1; s1 +=1;

4.Overload和Override的区别
Overload是方法重写,就是父和子类的多态表现,如果在子类中实现了父类的该方法,那么父类的该方法被重写.
Override是调用父类方法的

5.error和exception的区别
error是不可预见的,一般是系统的错误.
exception是程序可以捕捉的异常.

posted on 2005-11-20 00:23 jame 阅读(195) 评论(0)  编辑  收藏 所属分类: JAVA基础


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(3)

随笔档案

文章分类

文章档案

相册

收藏夹

UML

搜索

最新评论

阅读排行榜

评论排行榜