private void checkInvariants(){
  assert (wordsInUse == 0 || words[wordsInUse - 1] != 0);
  assert (wordsInUse >= 0 && wordsInUse <= words.length);
  assert (wordsInUse == words.length || words[wordsInUse] == 0);
}

private void checkInvariants ( ) { assert ( wordsInUse == 0 || words [ wordsInUse - 1 ] != 0 ) ; assert ( wordsInUse >= 0 && wordsInUse <= words . length ) ; assert ( wordsInUse == words . length || words [ wordsInUse ] == 0 ) ; }
every public method must preserve these invariants .
