Zydecx's Site

Debug code, debug life, debug today!

#Java编程思想

类型转换与反射(Java)

Time: , by zydecx

类型转换&检查

类型转换

  1. 强制类型转换

    强制类型转换通过(NewType)形式实现类型的强制转换。如下例所示,将aList强制转换为ArrayList类型。

    List aList = new ArrayList();
    ArrayList anArrayList = (ArrayList) aList;
...more

Class对象(Java)

Time: , by zydecx

关于Class对象,需要了解的是:

  • 每个类都有一个Class对象
  • 默认情况下,类通过“原生类加载器”从磁盘中加载;可以挂接其他的类加载器
  • Java采用动态加载机制;类在第一次被访问静态成员时被加载,从这个角度上讲,可以认为构造器为类的静态方法
...more

This is a magic phrase. You CANNOT see it(I'll really FULE you if you do that), but it does work. Why? You may feel confused. OK, at least it doesn't afftect your experience and it works. That is what we call MAGICE!