The private Keyword


The private keyword declares a member’s access as private. That is, the member is only visible within the class, not from any other class (including subclasses). Because access modifiers are not handled at instance level but at class level, private members of an object are visible from other instances of the same class!

Trainer.java (the private keyword)
public class Trainer {
  public static void main( String[ ] args ) {
    Dog dog = new Dog( );
    Trainer trainer = new Trainer( );
    trainer.teach( dog );
    trainer.list ( dog );
  }
  public void teach( Dog dog ) { dog.breed = "Wolf"; }
  public void list ( Dog dog ) { System.out.print( dog.breed ); }
}
class Dog {
  private String breed;
  public Dog( ) { breed = "Bull"; }
}
Output:           Result:

Review: JDBC Methods
    Which method does NOT exist in JDBC?

      execute
      executeInsert
      executeQuery
      executeUpdate
        Result:




      “We shall not cease from exploration    
      And the end of all our exploring    
      Will be to arrive where we started    
      And know the place for the first time.”    
      ― T. S. Eliot, Four Quartets