易截截图软件、单文件、免安装、纯绿色、仅160KB

JAVA规范学习——static成员初始化

class Super { static int taxi = 1729; }
class Sub extends Super {
static { System.out.print("Sub "); }
}
class Test {
public static void main(String[] args) {
System.out.println(Sub.taxi);
}
}
输出:1729
知识要点:
A reference to a class field causes initialization of only the class or interface
that actually declares it, even though it might be referred to through the name of a
subclass, a subinterface, or a class that implements an interface.
也就是说只有使用该类或者接口直接定义的类变量,才会激发该类的初始化;如果使用的是其父类定义的类变量,则子类不会被初始化
interface I {
int i = 1, ii = Test.out("ii", 2);
}
interface J extends I {
int j = Test.out("j", 3), jj = Test.out("jj", 4);
}
interface K extends J {
int k = Test.out("k", 5);
}
class Test {
public static void main(String[] args) {
System.out.println(J.i);
System.out.println(K.j);
}
static int out(String s, int i) {
System.out.println(s + "=" + i);
return i;
}
}
输出:
1
j=3
jj=4
3
 知识要点:
Initialization of an interface does not, of itself, cause initialization of any of its
superinterfaces.
The reference to J.i is to a field that is a compile-time constant; therefore, it
does not cause I to be initialized. The reference to K.j is a reference to a field
actually declared in interface J that is not a compile-time constant; this causes initialization
of the fields of interface J, but not those of its superinterface I, nor
those of interface K. Despite the fact that the name K is used to refer to field j of
interface J, interface K is not initialized.


相关文档:

java性能的优化(三)

    关于线程的操作,要注意如下几个方面。
    (1) 防止过多的同步
   
如上所示,不必要的同步常常会造成程序性能的下降。因此,如果程序是单线程,则一定不要使用同步。
    (2)
同步方法而不要同步整个代码段
   对某个方法或函数进行同步比对 ......

java php DES 加密解密

import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte ......

启动非java虚拟机方式下运行matlab

在非java虚拟机下运行matlab据说可以扩大内存,启动非java虚拟机下运行 matlab的方法有:
一.
1、右建点matlab快捷方式,选属性 ......

Delphi时间和Java时间的转换类。

这样一来,Delphi使用Webservice和JAVA通讯时,可以将DELPHI的时间直接传给JAVA。从而免去了时间字符串parse之间的消耗,提高的程序效率。
Delphi时间实质就是double类型,整数部分表示天,小数部分表示当天时间,每毫秒为1/86400000。考虑到时区的转换后,JAVA和DELPHI时间之间的转换类如下:
import java.util.Calendar ......

Java如何每5秒生成一个随机数


import java.util.Random;   
import java.util.Timer;   
import java.util.TimerTask;   
  
/**  
 * Java如何每5秒生成一个随机数  
 *   
 * @author Java人(java2000.net)  
 */&nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号