CSE 121
CSE 121
  • Home / Calendar
  • Syllabus
  • Assignments
  • Resubmissions
  • Exam
  • Getting Help
  • Course Staff
  • Grading Rubrics
  • Resources

  • Course Tools
  • EdStem
  • Grade Calculator
  • Anonymous Feedback
  • Acknowledgements

Java Basics, Printing


25sp ver.

Note: this is for the Spring 2025 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.

Search

Search the class website; related sections and pages will appear below. Note: this search is not as forgiving with typos as other search engines.