Java – Classes in same package

intellij-ideajava

I love the Intellij IDEA but i have been stacked on one little problem with Java imports.
So for example there is a package with name "example" and two different classes in it: A.java and B.java.

And i wanna get access to class "A" from class "B" without imports. Like this:

class A:

package example;

public class A{ ... some stuff here ...}

class B:

package example;

public class B{
    public static void main(String[] args){
        A myVar = new A();
    }
}

This code may not work, but it's doesn't matter. Trouble just with IDE and with its mechanism of importing classes.

So, problem is that i can't see A class from B. Idea says 'Cant resolve symbol' but i actually know that class A exists in package. Next strange is that complier works fine and there are no exceptions. Just IDEA can't see the class in the same package.

Does anybody has any ideas?

Best Solution

If they are in the same package, you can access A in class B without import:

package example;

public class B{
    public static void main(String[] args){
        A myA = new A();
    }
}