Hello.
Adding the private modifier to a method means that you can ONLY call it from within that class.
The public modifier means that you can access that method with the dot (.) operator from other classes.
public class Foo{
public Foo{
doSomethingInternal(); // Legal (This is the same as this.doSomethingInternal();
doSomethingExternal(); // Legal (This is the same as this.doSomethingExternal();
}
public void doSomethingExternal(){/*code*/}
private void doSomethingInternal(){/*code*/}
}
public class Bar{
public static void main(String[] args){
Foo foo = new Foo();
foo.doSomethingExternal(); // Legal
foo.doSomethingInternal(); // NOT Legal
}
}
Hope that clears things up =)