在学习Anroid时,总感觉Java知识不是太牢固,花了两天时间,阅读李兴华先生的基础书籍《Java实战经典》,有如下理解:
1.静态的东西是属于类的,而不是属于对象的。基于此种理解,认为: 静态代码块对类进行初始化,而构造方法对对象进行初始化。
2.区分传值和传址。例如数组为传址,引用数据类型。假设a[3],其在堆内存中为a[0],a[1],a[2]。而非其值。
3.多线程。继承Thread 或者实现 Runnable。在Android中,对数据进行缓冲(耗时操作)必须在子线程中进行处理,防止主线程假死,被系统关闭进程。使用Handler进行线程间通信。此外,还有 join,notify,interrupt,wait,yield,
4.Java对可变参数的支持。增强for循环。如下:
public void tell(String...args){ for(String arg:args) System.out.println("welcome"+" "+arg); }
使用JUnit单元测试:
@Test public void textTell(){ new ABC().tell("aaa","bbb","xxx","hhh"); }
输出结果:
welcome aaa
welcome bbb
welcome xxx
welcome hhh
5.反射机制。BeanUtils的使用:
@Test public void testBeanUtils() throws IllegalAccessException, InvocationTargetException{ Person p1 = new Person(); BeanUtils.setProperty(p1,"name","aaa"); BeanUtils.setProperty(p1, "age", 30); System.out.println(p1); }
6.Override。子类不能比父类拥有更严格的权限 。
7.使用JDBC时,ResultSet中所有类型都可以使用 getString()取得。
8.对打印流(Printer),比较器(Comparable),和 JDBC2.0的关注。