1 of 61

Introduction to 61B, Java

1

Lecture 1

CS61B, Fall 2026 @ UC Berkeley

Lecturers: Manuel Sabin, Josh Hug

2 of 61

Welcome to 61B

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

2

3 of 61

Layers of Abstraction

In 61A, you learned that programming is done in layers of abstraction.

  • You learned how to use a list.
  • But never how a list was implemented.

x = [3, 4, 5]

x.append(6)

4 of 61

Layers of Abstraction

In 61A, you learned that programming is done in layers of abstraction.

  • You learned how to use a list.
  • But never how a list was implemented.

x = [3, 4, 5]

x.append(6)

Us, in 61B

5 of 61

61B and Lists

Over the first five weeks of 61B, we’ll explore two radically different choices for how one can implement a list.

  • Along the way, we’ll also learn more industrial strength techniques for building software.

x = [3, 4, 5]

x.append(6)

Us, in 61B

6 of 61

61B Overview

What is 61B about?

  • Writing code that runs efficiently.
    • Good algorithms.
    • Good data structures.
  • Writing code efficiently by hand.
    • Designing, building, testing, and debugging large programs (including programs that implement and cleverly utilize data structures).
    • Use of programming tools.
      • git, LLMs, IntelliJ, JUnit / Truth, and various command line tools.

​

Assumes solid foundation in programming fundamentals, including:

  • Object oriented programming, recursion, lists, maps, and trees.

​

Will not cover AI workflows.

  • Will hopefully have an optional project or two for those interested in exploring.

7 of 61

Java

In our course, we’ll use the Java programming language.

  • Code runs much faster than Python.
  • Includes interesting programming language features missing in Python.
    • Static typing.
    • Arrays.
    • Subtype polymorphism.
  • Extremely popular language.

Python, Scheme, SQL

61A

61B

61C

Java

C, Assembly

8 of 61

Other Reasons to Take 61B

Other great features of 61B:

  • We cover the most popular topics for job interview questions in software engineering.
    • Examples: Hash tables, binary search trees, quick sort, graphs, Dijkstra’s algorithm.
  • Some really cool math. Examples:
    • Asymptotic analysis.
    • Resizing arrays.
    • The isometry between self-balancing 2-3 trees and self-balancing red black trees.
    • Graph theory.
    • P vs NP.
  • Once you’re done: the confident sense that you can build any software.

​

9 of 61

About Us (Josh)

Josh Hug: Berkeley faculty since 2014.

  • EE B.S. from UT Austin in 2003.
  • EECS Ph.D. from UC Berkeley 2011.
  • Taught at Princeton 2011-2014.
  • 15th time teaching this class.
    • This is the second run of the 5th major revision of the course. More on that later.
  • Co-teaching CS70 with Manuel.
    • You’ll see me in 61B more at the first half of the semester.

9

10 of 61

About Us (Manuel)

Manuel Sabin: 2nd year as Berkeley faculty

  • Math & Applied CS B.A. from CSU Sacramento in 2014.
  • EECS Ph.D. from UC Berkeley 2020.
  • Taught 70 and 61A last year.
  • Teaching 70 this semester as well (who is taking 70 w/ me this semester?)
  • 1st time teaching this class!
  • Co-teaching CS70 with Josh.
    • You’ll see me in 61B more at the second half of the semester.

​

​

11 of 61

Question for You

What do you hope / expect to learn from this class? Why are you taking it?

  • My major requires it.
  • Seems interesting.
  • Community college does not articulate it.
  • Data structures are important.
  • Build cool things.
  • Stats major - the R language is not appealing to me.
  • Help you on leetcode.
  • Developing my github.

​

Who are you?

  • ​

12 of 61

61B Logistics

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Structure and Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

12

13 of 61

Joining the Course

Course staff does not control getting into the course.

  • Contact a major advisor if you have questions.

​

Being added to course platforms (Ed, Gradescope) is manual. We do this every day. Please do not email us (cs61b@berkeley.edu) asking to be added to the platforms unless it’s been more than 2 days since you joined the course.

​

If you are a pending concurrent enrollment student, you should be added to bCourses, Ed, and Gradescope 1–2 days after you've submitted your application.

  • We cannot process/approve applications until the department tells us to. We will post on Ed if there are updates.
  • Do not email course staff about getting added to the course platforms unless it’s been more than 2 days since you’ve submitted your application.

14 of 61

DSP (Disabled Students' Program)

If you have DSP accommodations, please submit your letter through the DSP portal as soon as possible!

15 of 61

Course Components

Lectures (~40/hours) provide you with an introduction and a foundation.

​

You’ll learn most of what you learn in the class with practice (~160-200 hours):

  • Programming (programming homeworks, projects, discussion section, old exams).
  • Solving interesting problems (theory homeworks, old exams, discussion section).

​

​

​

​

​

Before

After

16 of 61

Class Phase

This class is divided into three phases:

  • Phase 1 (weeks 1 - 5): Intro to Java and Data Structures.
    • Learning core programming skills in the context of list implementations.
    • All coding work is solo.
    • Moves VERY fast. Lots of little deadlines.
    • Two mini-projects on data structures.
      • Midterm 1 will test programming skills developed on HWs / mini-projects.
  • Phase 2 (weeks 6 - 10): Data Structures (and a little Software Engineering).
    • All coding work is solo.
    • Moves moderately fast.
    • One data structures design project.
    • Midterm is more theoretical.
  • ​
  • Phase 3 (weeks 11 - 15): Algorithms and Software Engineering.
    • Coding work is entirely dedicated to final project, done in pairs.
    • Slower pace.

17 of 61

Class Phase

This class is divided into three phases:

  • Phase 1 (weeks 1 - 5): Intro to Java and Data Structures.
    • Learning core programming skills in the context of list implementations.
    • All coding work is solo.
    • Moves VERY fast. Lots of little deadlines.
    • Two mini-projects on data structures.
      • Midterm 1 will test programming skills developed on mini-projects.
  • Phase 2 (weeks 6 - 10): Data Structures (and a little Software Engineering).
    • All coding work is solo.
    • Moves moderately fast.
    • One data structures design project.
    • Midterm is more theoretical.
  • ​
  • Phase 3 (weeks 11 - 15): Algorithms and Software Engineering.
    • Coding work is entirely dedicated to final project, done in pairs.
    • Slower pace.

18 of 61

Evaluation

Four types of points in this class:

  • Low effort, everyone should get them: Weekly Surveys, Course Evaluations
    • Median score is 100%
  • Medium effort, everyone should get them: HWs, Mini-Projects, Attendance
    • Median score is 100%
  • High effort, everyone should get them: Design Projects
    • Median score is 100%
  • High effort, not everyone gets them: Exams
    • Target mean score is 65%
    • Final exam score can replace midterms if you have a bad midterm (or two).
    • Exam scores are not curved (don’t want this class to feel like a competition).

​

Full details around point distributions, letter grade assignments, grade replacement, etc. are on the website.

19 of 61

Lateness Policies

Homeworks, mini-projects, and design projects turned in late will have 5% deducted per 12 hours (with a small secret grace period).

  • Extensions are available if you have DSP accommodations.
  • Capped points are intended to handle most contingencies.
    • Example: Each mini-project is worth 180 points, for a total of 4 * 180 = 720 points, but mini-project category is worth only 600.
    • But if you have something severe, reach out with the extenuating circumstances form and we can discuss.

​

No extensions for anyone on weekly surveys (we effectively drop the lowest 4).

20 of 61

Exams

There will be three exams, all on paper:

  • Mini-Midterm 1 (450 points): 70 minutes, 9/23/26, 8:10- 9:20 PM.
  • Midterm 2 (1100 points): 110 minutes, 11/4/26, 8:10 - 10:00 PM.
  • Final (1700 points): 170 minutes.

​

More about exams later.

21 of 61

Labs and Discussion Sections

There are two types of meetings other than lecture:

  • Discussion: 1 hour group based problem solving using a paper worksheet.
  • Lab: 2 hour group based problem solving using your computer.

​

To attend discussion or lab, fill out the Discussion / Lab matching form: https://forms.gle/fc55vdZSYqLrDKJT9

  • You must fill out this form to attend discussion or lab.
  • We will assign you to a discussion and/or lab time.
  • We will assign you to a discussion and/or lab group.
  • It’ll be possible to change assignments later.
  • Attendance counts towards your grade if you opt-in.

​

Exception: Just this week, lab is drop-in.

  • Come to any lab.
  • No assigned groups.

22 of 61

Bridge Section (for Those with Shakier Foundations)

If you had B or lower in your prerequisite class (CS61A, CS88), if you took E7, or if you find this week’s lab problem below challenging:

​

​

​

​

​

​

Then I strongly recommend attending the Bridge Section(s):

  • 5-7 PM Monday

​

​

And also make sure you get started on HW 1 today and HW2 by Friday.

23 of 61

Point Breakdown and Attendance Policy

​

Points

Surveys

120

Homeworks

280

Mini-Projects

600

Design Projects + Attendance

1900

Mini-Midterm 1

450

Midterm 2

1100

Final Exam

1700

Total

6150

If you opt in to discussion + lab track:

  • Attendance 300 pts, Projects 1600 pts

​

If you opt in to only one track:

  • Attendance 150 pts, Project 1750 pts

​

If you opt out of discussion and lab

  • Attendance 0 pts, Projects 1900 pts

​

Attending lecture:

  • 6 exam recovery points (ERP) for every lecture attended, maxing out at 150 ERP.
  • ERPs only help if your exam score is < 70%.

​

tl;dr; Get points for being at things, but if you opt-out and do well, no net penalty.

24 of 61

LLMs / Plagiarism Policy

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Structure and Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

24

25 of 61

A Chat with a Large Language Model

26 of 61

A Chat with a Large Language Model [1 minute and 15 seconds later]

​

27 of 61

Why Learn Programming at All?

Given that industry programmers mostly do not write code anymore, you may ask: Why are we bothering to learn to write code?

  • Rocket engineers don’t weld.
  • Civil engineers don’t pour concrete.

​

We’ll discuss this together in more detail in a future lecture!

  • Short version: Build fundamental problem solving and problem decomposition skills.

28 of 61

Surprising Fall 2025 Observations

On midterm 1 (programming): 10% of students earned less than 10% on midterm 1.

  • Conjecture: Students with shaky foundations used LLMs to get through early assignments, and missed out on learn to program.

29 of 61

Surprising Fall 2025 Observations

Estimate: 30 to 50% of students turned in LLM code on Project 4 (a design project).

  • This was strictly forbidden.
  • And the projects are also arguably the main reason to take the course.
    • Fun.
    • Build independent software engineering skills.
  • Among the top 35 students, LLM use was much less common (only 3/35).

​

Spring 2026 went better because we had students do a programming-on-a-computer exam.

  • Not possible this semester, unfortunately (no space).
  • Instead, we’ll be using something called provenance for assignments after HW1 (more next lecture).

30 of 61

LLM Recommendations

We recommend using LLMs minimally when doing work for the class. Guidelines:

  • Don’t use LLM plugins for IntelliJ. Don’t use Cursor, Claude Code, etc.
  • LLMs shouldn’t write any of the code you turn in.
  • Don’t provide assignment specs to LLMs.
  • Don’t give your code to LLMs and say “where is the bug?” unless you are REALLY stuck.
    • Use the tools we suggest and talk to instructors or classmates first.

​

It is reasonable to use LLMs as a tutor.

  • But when you can, enjoy the richer experience of talking to staff or fellow students.
  • Be human!!

31 of 61

LLM Usage by Staff

All assignments, worksheets, readings, and exam problems are designed by human staff (mostly Josh).

  • We will use LLMs for less interesting stuff, e.g. autograders, typesetting details for exams, proofreading.

​

Josh’s personal strong belief: AI art and AI writing is bad and alienating.

32 of 61

Hello World

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

32

33 of 61

Intro to Java

Let’s try writing some simple Java programs.

  • First I’ll write them in Python (~99% of you have seen Python).
  • Then I’ll write the equivalent Java program.

​

If you’ve never written in code in Python or Java, this will be a little harder for you, but still comprehensible.

​

​

This section might be a bit boring if you have Java experience.

​

​

(See video or code linked on course website)

Lecture code repository: https://github.com/Berkeley-CS61B/lectureCode-fa26

34 of 61

Coding Demo: Hello World

hello.py

void main() {

​

}

HelloWorld.java

35 of 61

Coding Demo: Hello World

print("hello world")

hello.py

void main() {

IO.println("hello world");

}

HelloWorld.java

36 of 61

Java and Object Orientation

Reflections on Hello World:

  • We use { } to delineate the beginning and ending of things (e.g. functions).
  • We must end lines with a semicolon.
  • The code we want to run must be inside a function called main.

37 of 61

Hello Numbers

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

37

38 of 61

Coding Demo: Hello Numbers

x = 0;

while x < 10:

print(x)

x = x + 1

hellonumbers.py

void main() {

​

x = 0;

while (x < 10) {

IO.println(x);

x = x + 1;

}

​

​

}

HelloNumbers.java

39 of 61

Coding Demo: Hello Numbers

x = 0;

while x < 10:

print(x)

x = x + 1

hellonumbers.py

void main() {

int x;

x = 0;

while (x < 10) {

IO.println(x);

x = x + 1;

}

​

​

}

HelloNumbers.java

40 of 61

Coding Demo: Hello Numbers

x = 0;

while x < 10:

print(x)

x = x + 1

hellonumbers.py

void main() {

​

int x = 0;

while (x < 10) {

IO.println(x);

x = x + 1;

}

​

​

}

HelloNumbers.java

41 of 61

Coding Demo: Hello Numbers

x = 0;

while x < 10:

print(x)

x = x + 1

​

x = "horse" # works

print(x)

hellonumbers.py

void main() {

​

int x = 0;

while (x < 10) {

IO.println(x);

x = x + 1;

}

x = "horse"; // doesn't work

String x = "horse"; // doesn't work

}

HelloNumbers.java

42 of 61

Coding Demo: Hello Numbers

x = 0;

while x < 10:

print(x)

x = x + 1

​

# crashes here

print(5 + "horse")

hellonumbers.py

void main() {

​

int x = 0;

while (x < 10) {

IO.println(x);

x = x + 1;

}

​

x = "horse"; // program doesn't run

}

​

HelloNumbers.java

43 of 61

Java and Static Typing

Reflections on Hello Numbers:

  • Before Java variables can be used, they must be declared.
  • Java variables must have a specific type.
  • Java variable types can never change.
  • Types are verified before the code even runs!

​

Java is statically typed!

  • All variables, parameters, and methods must have a declared type.
  • That type can never change.
  • Expressions also have a type, e.g. “larger(5, 10) + 3” has type int.
  • The compiler checks that all the types in your program are compatible before the program ever runs!
    • e.g. String x = larger(5, 10) + 3 will fail to compile.
    • This is unlike a language like Python, where type checks are performed DURING execution.

44 of 61

Larger

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

44

45 of 61

Coding Demo: Larger

def larger(x, y):

if (x > y):

return x

return y

larger.py

int larger(x, y) {

if (x > y) {

return x;

}

return y;

}

LargerDemo.java

46 of 61

Coding Demo: Larger

def larger(x, y):

if (x > y):

return x

return y

larger.py

int larger(int x, int y) {

if (x > y) {

return x;

}

return y;

}

​

​

​

​

​

LargerDemo.java

47 of 61

Coding Demo: Larger

def larger(x, y):

if (x > y):

return x

return y

​

print(larger(-5, 10))

larger.py

int larger(int x, int y) {

if (x > y) {

return x;

}

return y;

}

​

void main() {

IO.println(larger(-5, 10));

}

LargerDemo.java

48 of 61

Larger: Reflections

  • To define a function in Java, we simply write the type of the method followed by the name (there is no “def” keyword).
  • We will see alternate ways of defining functions later.
  • All parameters of a function must have a declared type, and the return value of the function must have a declared type. Functions in Java return only one value!

49 of 61

Reflections on Static Typing

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

49

50 of 61

Reflections on Static Typing

Static typing is that thing in Java where everything has a declared type, and that type never changes (i.e. it is static).

​

The Good:

  • Avoids bugs.
  • Faster.
  • Easier to read and reason about.

​

The Bad:

  • Way more verbose.
  • May need more than one function to cover all the types you want to cover.

​

51 of 61

Reflections on Static Typing (My Answers)

The Good:

  • Catches certain types of errors, making it easier on the programmer to debug their code.
  • Type errors can (almost) never occur on end user’s computer.
  • Makes it easier to read and reason about code.
  • Code can run more efficiently, e.g. no need to do expensive runtime type checks.

�The Bad:

  • Code is more verbose.
  • Code is less general, e.g. would need a second larger function to compare non-integers like 5.5.

52 of 61

Compilation (extra)

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

52

53 of 61

Fall 2026 note: We skipped these slides. We’ll return to them in a much later lecture.

54 of 61

Compilation vs. Interpretation

In Java, compilation and interpretation are two separate steps.

  • In my sublime text demo, this two step process was hidden from you.
  • Let’s go try this two step process manually from the command line.

​

​

​

​

Hello.java

Hello.class

javac

java

stuff

happens

Compiler

Interpreter

Why make a class file at all?

  • .class file has been type checked. Distributed code is safer.
  • .class files are ‘simpler’ for machine to execute. Distributed code is faster.
  • Minor benefit: Protects your intellectual property. No need to give out source.

Note: .class files are easily reversible into similar looking Java files.

You can learn more about all this in 61C and particularly 164.

55 of 61

Demo: Compilation in Terminal

jug ~/.../intro1

$ ls

HelloWorld.java

​

$ javac HelloWorld.java

​

$ ls

HelloWorld.class HelloWorld.java

​

$ java HelloWorld

Hello World!

Note: This is a very old school (but sometimes useful) way of interacting with Java code. We won’t do this in 61B.

56 of 61

IntelliJ

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

56

57 of 61

Example Workflows

There are many different workflows for writing programs.

  • Text editor + command line: (CS61A, CS88). We just did this.
    • Text editor: Writing your code.
    • Command line: Running your code.
  • Jupyter Notebooks: (Data 8, E7)
    • Write and run code in the same environment.
  • Integrated Development Environment (IDE): (61B)
    • Write code and run code in the same environment.
    • Tons of additional features like a debugger, code autocomplete, continuous syntax checking, decompilation (from .class to .java), etc.

​

Let’s see what our programs look like in the IDE for our course.

58 of 61

IntelliJ Screenshot

Example feature: IntelliJ automatically and continuously detects syntax errors.

59 of 61

Admonition

Our expectation is that everyone in this class is using IntelliJ.

  • It is not strictly required, but staff will provide no support for other tools or workflows.

60 of 61

HW1: Due Friday!

Lecture 1, CS61B, Fall 2026

​

  • Welcome!
    • Welcome to 61B
    • 61B Logistics
    • LLMs / Plagiarism Policy
  • Our First Java Programs
    • Hello World
    • Hello Numbers
    • Larger
    • Reflections on Static Typing
  • Workflow
    • Compilation
    • IntelliJ
  • HW1: Due Friday!

60

61 of 61

Time to Go Learn Java Basics!

I am not going to spend time in this class covering for loops, while loops, etc. in Java.

  • You’ve seen this all before in some other language.

​

Lab 1 is out.

  • Intended for doing in person with other people. Come to any lab, just this week.
  • But you can also complete it on your own.
  • No points for doing the exercises. Lab points are for attendance, not completion.

​

HW1 is out, due Friday at 11:59 PM!

  • HW1 is setting up your computer to run Java code using IntelliJ.