总结:按顺序执行
public class StaticTest {
public static String API_DEV_BASE_URL = "http://192.168.10.10/";
public static String API_PRO_BASE_URL = "http://api.appblog.cn/";
public static String API_BASE_URL = API_PRO_BASE_URL;
public static String LOG_REPORT_URL = API_BASE_URL + "log";
static {
API_BASE_URL = API_DEV_BASE_URL;
}
public static void main(String[] args) {
System.out.println(LOG_REPORT_URL);
}
}
输出结果:
http://api.appblog.cn/log
public class StaticTest {
public static String API_DEV_BASE_URL = "http://192.168.10.10/";
public static String API_PRO_BASE_URL = "http://api.appblog.cn/";
public static String API_BASE_URL = API_PRO_BASE_URL;
static {
API_BASE_URL = API_DEV_BASE_URL;
}
public static String LOG_REPORT_URL = API_BASE_URL + "log";
public static void main(String[] args) {
System.out.println(LOG_REPORT_URL);
}
}
输出结果:
http://192.168.10.10/log