Intro1 Study Guide
Author: Josh Hug

Lecture Code

Code from this lecture available at https://github.com/Berkeley-CS61B/lectureCode-fa20/tree/master/intro1.

Overview

Our First Java Program. Printing Hello World is as easy as:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}

Key Syntax Features. Our first programs reveal several important syntax features of Java:

Static Typing. Static typing is (in my opinion) one of the best features of Java. It gives us a number of important advantages over languages without static typing:

There are downside of static typing, to be discussed later.

Coding Style. Coding style is very important in 61B and the real world. Code should be appropriately commented as described in the textbook and lectures.

Command line compilation and execution. javac is used to compile programs. java is used to execute programs. We must always compile before execution.

Exercises

None for this lecture. However, we strongly encourage you to complete the optional HW0, which covers a bunch of basic Java syntax.