Cannot `import static` static nested class?

前端 未结 2 1448
情深已故
情深已故 2021-01-12 09:52

I have a class A with a static nested class inside it called B:

import static A.B.*;

class A {
    static class B {
        static         


        
2条回答
  •  孤独总比滥情好
    2021-01-12 10:31

    It should be

    import .A.B.*;
    

    If A is in the default package, this will fail.

    Last, it's not a good practice to import *. Just import only the things that you need, in this case - import static .A.B.x; if you're gonna use only the x variable.

提交回复
热议问题