24au ver.
Note: this is for the Autumn 2024 iteration of CSE 121. Looking for a different quarter? Please visit https://courses.cs.washington.edu/courses/cse121/.
Structure of a Java program¶
public class Name {
    public static void main(String[] args) {
        statement;
        // more statements here...
        statement;
    }
}
Printing¶
(displays output in the console window)
| Code | Description | 
|---|---|
System.out.print("text"); |  prints text |  
System.out.println("text"); |  prints text and moves to a new line |  
System.out.println(); |  prints a blank line | 
Comments¶
(notes written in the program for the programmer to read)
/* text
 * (multiple lines)
 */
// text (one line)
Example
/* CSE 121, Stan Smith
 * This program prints the steps of my favorite recipe.
 */
// This code displays the preamble of the US Constitution.