本帖最后由 王德升 于 2012-7-14 20:17 编辑
一:
package cn.itcast.day01;
public class StaticImport
{
public static void main(String[] args)
{
int x = 1;
try {
x++;
} finally {
System.out.println("haha");
System.out.println("hahaha");
}
System.out.println("你好,我的Ecs"+x);
}
//为什么我在这里导入syso然后按ALT+/就倒不出来呢?
}
二:
package cn.itcast.day01;
public class ReflectTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "abc";
Class cla1 = String.class;
Class cla2 = str.getClass();
try
{
Class cla3 = Class.forName("java.lang.String");//这句话为什么会有异常呢?
}
catch(Exception e)
{
throw new RuntimeException("出错了");
}
System.out.println(cla1 == cla2);
try
{
System.out.println(cla1 == cla3);//这句话还会报异常
}
catch(Exception e)
{
throw new RuntimeException("不对啦");
}
}
}
//我这样写为什么还会报错? |