gpt4 book ai didi

java - 静态最终变量在重建后具有旧值

转载 作者:行者123 更新时间:2023-12-01 21:34:22 24 4
gpt4 key购买 nike

这是我的Config类:

public class Config
{
public static final String urlApi = "http://127.0.0.1/api/";
}

每当我想更改位置时,我都必须更改此变量的值:

public class Config
{
public static final String urlApi = "http://192.168.50.101/api/";
}

在本例中,值为:

"http://192.168.50.101/api/"

但在 Debug模式下,我看到“urlApi”具有旧值、旧IP地址。有点奇怪。我如何解决它 ?

最佳答案

我解决了这个问题。我转到“清理项目”,然后再次“创建项目”,我认为这就是解释。

Note: If a primitive type or a string is defined as a constant and the value is known at compile time, the compiler replaces the constant name everywhere in the code with its value. This is called a compile-time constant. If the value of the constant in the outside world changes (for example, if it is legislated that pi actually should be 3.975), you will need to recompile any classes that use this constant to get the current value.

关于java - 静态最终变量在重建后具有旧值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37079460/

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