Short name for imported constant class fields

后端 未结 3 819
清歌不尽
清歌不尽 2021-01-21 01:48

I have a java program with hundreds of configuration constants:

public static final String C1=\"C1\";
public static final String C2=\"C2\";

Sin

相关标签:
3条回答
  • 2021-01-21 02:31

    The answer is Static import, you can solve by using it:

    import static mynamespace.MyClassConstants.*;

    See also:

    • Static import
    • Java doc: static import
    0 讨论(0)
  • 2021-01-21 02:38

    You should static import. More details are here http://javapapers.com/core-java/what-is-a-static-import-in-java/

    You have it like : import static mynamespace.MyClassConstants.*;

    0 讨论(0)
  • 2021-01-21 02:47

    try

    import static mynamespace.MyClassConstants.*;
    

    then

    myMethod( C1, C2 );  should work
    
    0 讨论(0)
提交回复
热议问题