Braces

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

The person might be you. Comments are often notes to yourself about what something is, or why you did something the way you did.

Braces

Another thing to notice in programs is that for every left brace ...

{

there is a right brace

}

... that matches. Usually there will be sets of matching braces inside other sets of matching braces. The first brace in a class (which has to be a left brace) will match the last brace in that class (which has to be a right brace). A brace can match just one other brace. Use indenting to help the human reader see how the braces match (and thereby see how the program has been constructed), as in the example:

class Haiku
{
  public static void main ( String[] args )
  {
    System.out.println( "On a withered branch" );
    System.out.println( "A crow has just alighted:" );
    System.out.println( "Nightfall in autumn." );
  }
}

There are many styles of laying out a program. If you are reading a printed text book in addition to these notes, it is likely that it uses a different style.

QUESTION 16:

Mentally circle the matching braces in the program.