Is there a simple way to call static methods / properties in java?

java:
public class App {
    public static String name = "grayVTouch";
    public static void say(){
        System.out.println(App.name);
    }
}

in the above calling methods, if the class name is changed, all related static calls need to be changed. It is troublesome. Is there a simple operation like PHP ?

PHP:
class Test {
    public static $name = "grayVTouch";
    public static function say(){
        // self 
        echo self::$name;
    }
}
Nov.04,2021

public class App {
    public static String name = "grayVTouch";
    public static void say(){
        System.out.println(name);
    }
}
Why not just write the

code like this? The meaning of self is not found at all.


does not seem to have. For the time being, you can modify only one place of the reference class
with the static import of
.
2 use IDE's refactor


when you modify it, your IDE should modify the referenced places as well. Don't worry about this

.
Menu