Visible to the class, package, and subclass.
Let's see an example with the class Test.
public class Test{
public int number = 2;
public Test(){
}
}
Now let's try to create an instance of the class. In this example, we can access number
because it is public
.
public class Other{
public static void main(String[] args){
Test t = new Test();
System.out.println(t.number);
}
}