gpt4 book ai didi

java - 静态在此示例程序中如何工作?

转载 作者:行者123 更新时间:2023-12-02 00:11:59 24 4
gpt4 key购买 nike

 import java.util.*;
import net.rim.vm.*;

public class AddressBook {

static Vector addresses;
static PersistentObject persist;


static {
// Hash of "net.rim.sample.AddressBook".
long KEY = 0xa3b3159378f59a29L;
persist = PersistentStore.getPersistentObject( KEY );
if( persist.getContents() == null ) {
persist.setContents( new Vector() );
persist.commit();
}
addresses = (Vector)persist.getContents();
}
}

void add( Address a ) {
addresses.addElement( a );
persist.commit();
}
}

Source

最佳答案

  1. 该类已加载
  2. 静态实例变量已初始化

    静态 vector 地址;

    静态持久对象持久化;

  3. 然后是static block已执行。

    静态{....}

关于java - 静态在此示例程序中如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12635021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com