博客主机

Java Initializer Java 初始化程序

程序中的初始化是指对类中域field(就是属性property)和局部变量(local variable)赋初值。在Java中初始化分为显式初始化(Explicitly)和隐式初始化(Implicitly)。 域的隐式初始化(Field Implicit Initialization) Java虚拟机负责对域进行隐式初始化;隐式初始化总是在任何代码之前,因为虚拟机要保证数据的正确性,这成全了粗心的coder不必为初始化担心。 实例域(instance field)的隐式初始化: ...

Get main class name

1 2 3 4 5 6 7 8 9 Map a = Thread.getAllStackTraces(); for(Thread t : a.keySet()){ if ("main".equals(t.getName())){ StackTraceElement[] stack = t.getStackTrace (); StackTraceElement main = stack[stack.length - 1]; String mainClass = main.getClassName (&...

清理:终结与垃圾回收

清理:终结与垃圾回收这里要明白这么几点1、垃圾回收器只能回收由new产生的对象,如果你使用或产生了非new产生的对象,垃圾回收器是不知道如何把他清理掉的 。这个时候就要使用到finalize()。2、垃圾回收器的运做方式是这样的,当垃圾回收器打算开始释放你的对象所占用的资源时,会先调用finalize(),并且在下一次垃圾回收动作放生的时候才回收该对象所占用的资源,如果使用finalize(),他便会让你得以在垃...

Java类加载揭秘(zz)

类加载是java语言提供的最强大的机制之一。尽管类加载并不是讨论的热点话题,但所有的编程人员都应该了解其工作机制,明白如何做才能让其满足我们的需要。这能有效节省我们的编码时间,从不断调试 ClassNotFoundException, ClassCastException的工作中解脱出来。   这篇文章从基础讲起,比如代码与数据的不同之处是什么,他们是如何构成一个实例或对象的。然后深入探讨java虚拟机(JVM)是如何利用类加...

non-null

The benefits of non-null sets also extend to other data structures. Collections, maps, and arrays should never be null, but they should be empty if they don't have data.

Marker Interfaces

Marker interfaces are that which don't declare any method or atrributes. It is used to mark classes conceptually. By using marker interfaces, a developer can tag certain code without complicating its inheritance structure. For example, Serializable is a marker interface that you see all over the place. This interface marks a class as having the ability to be flattened and se...
Copyright © 小小的数据技术梦想 保留所有权利.   Theme  Ality 浙ICP备12043346号-1

用户登录

分享到: