✕ Close

Week 14 · 14.1 · Mon, Nov 2 · The Bigger Picture: ACT-style reading

The Shape of a Java Program: Why Java Looks the Way It Does

1 This section explains where the semicolons and the method named main in a Java program came from, and how a reader can find the start and the end of each part of any Java program.

Punctuation From Bell Labs

2 Between 1969 and 1973, Dennis Ritchie created a programming language called C at Bell Labs in Murray Hill, New Jersey. According to Ritchie, the most creative period in the language's development was 1972. C grew out of an earlier language called B, and B in turn grew out of a language called BCPL.

3 BCPL let a programmer leave out most semicolons, as long as a statement ended at the end of a line. B and C dropped that convenience, so most statements in those languages end with a semicolon. A semicolon therefore marks exactly where one instruction stops and the next one begins. Writing in 1993, Ritchie called C one of the dominant languages of the day, and he named C++ among its descendants.

A Language Meant to Look Familiar

4 In June 1991, James Gosling began a project at Sun Microsystems and named his new language Oak. The project aimed to build software for many kinds of network devices and small computers inside other machines. By the time Sun announced it in 1995, the language was named Java.

5 Gosling and Henry McGilton explained one design choice in a 1996 paper about Java. The team decided against building Java on C++, yet they kept Java "looking like C++ as far as possible." A familiar look meant that programmers who already knew C++ could move to Java and be productive quickly. For that reason, Java statements end with semicolons, as C statements do, and every Java program starts at a method named main, much as a C program starts at a function named main.

6 A familiar name spread as well. A language for web pages called LiveScript was renamed JavaScript because it follows most of Java's expression syntax, but JavaScript and Java are different languages. In September, the class saw three languages in one web page: HTML gives the page its structure, CSS sets how the parts of a page look, including size and color, and JavaScript makes the page respond. None of the three is Java. HTML and CSS describe a page, and JavaScript gives it behavior, while Java is a fourth language with a shape of its own. Figure 1 shows the path from the semicolons of C, to the familiar look of Java, to the shape that every Java program shares.

The Shape Every Program Shares

7 According to Oracle's Java tutorial, every Java application must contain a main method, which is the entry point, the place where the program begins. The code for a class sits between an opening brace, {, and a closing brace, }. A statement is one instruction, roughly like a sentence, and a statement such as a println ends with a semicolon. The program below has a class named Greeting, a main method inside it and two statements inside main.

1public class Greeting
2{
3    public static void main(String[] args)
4    {
5        System.out.println("Hello");
6        System.out.println("Who dat");
7    }
8}
Hello
Who dat

8 Braces always come in pairs, and in this program the pair for main, on lines 4 and 7, sits inside the pair for the class, on lines 2 and 8. The inner pair closes first, so the last brace in the program belongs to the class. When Java runs the program, it goes to main and carries out its statements from top to bottom, so Hello is shown before Who dat.

9 Today's question asks how a person reading a long program could find where it starts and tell where each part stops. The word main marks the start, and each opening brace has a closing partner that marks where its part stops. On today's bench, the job is to click the class name, main, each statement and each semicolon, and to match every brace with its partner, first in short programs and then in longer ones.

Summary

10 Semicolons that end statements came to Java from C, which Dennis Ritchie created at Bell Labs in the early 1970s. James Gosling's team kept Java looking like C++, a descendant of C, so that programmers would find it familiar. Every Java program has the same outline: a class, a main method inside it and statements inside main, with a pair of braces around each part. A reader finds the start of a program at main and finds the end of each part at the brace that closes it.

Sources: Ritchie, The Development of the C Language (1993); Gosling and McGilton, The Java Language Environment (1996); Rambo, Sun Microsystems Introduces Java (EBSCO Research Starters, 2021); Oracle, The Java Tutorials: A Closer Look at the Hello World Application and Expressions, Statements, and Blocks; MDN Web Docs, Introduction (JavaScript Guide), What is JavaScript? and JavaScript (Glossary); course repository, Bench Basics B11 job data (2026).

Figure 1. Semicolons that end statements came from C in the early 1970s, Java kept C++'s familiar look in 1995, and every Java program has the same nested shape.
ACT-style reading · 9 questions

Read the passage on the left. Answer each question by clicking a choice: the right answer turns green, and a wrong one tells you why. Questions point to paragraph numbers, as on the ACT.

1. Main idea

The main purpose of the passage is to:

2. Detail

According to paragraph 3, how did B and C differ from BCPL?

3. Words in context

As it is used in paragraph 3 ("B and C dropped that convenience"), the word convenience most nearly means:

4. Purpose

The quotation "looking like C++ as far as possible" in paragraph 5 mainly serves to:

5. Inference

Based on paragraphs 7 and 8, a program has its main method's braces on lines 3 and 9 and its class's braces on lines 2 and 10. Which brace closes the class?

6. Sequence

According to the passage, which of these happened FIRST?

7. Cause and effect

According to paragraph 5, why did the Java team keep Java looking like C++?

8. Detail

According to paragraph 7, what is the entry point of a Java application?

9. Author's claim

Which statement from the passage best answers how a reader finds where a long program starts and where each part stops?