Search code examples
javaintellij-idea

IntelliJ IDEA not showing member field, does not Autocomplete on static methods


Problem as picture bellow, is there any option to enable showing member abc?

enter image description here

I am using IntelliJ IDEA CE 2017.2.1 with JDK 9+179.

Here is the sample code above:

    public class Test {

        @FunctionalInterface
        interface IF {
            String abc = "abc";

            void apply();
        }

        public static void main(String[] args) {
            IF theIF = ()->{};

            System.out.println(theIF.abc); // I can print `abc` value here, but...
            theIF. // DOT here(press ctrl + space) not show member `abc`
        }
    }

Solution

  • This is accessing static member with instance qualifier, and is better done as IF.abc. Therefore code completion doesn't offer it right away, but if you press Ctrl+Space second time, it should be suggested.