1. try/catch — handling exceptions
- Wrap risky code in
try { }
- Catch the exception in
catch (Exception e) { }
- Without a try/catch, an uncaught exception halts the program
- Always catch
IOException around file operations
try {
String[] names = { "Ezra", "Ian" };
System.out.println(names[99]);
}
catch (Exception e) {
System.out.println("Out of range!");
e.printStackTrace();
}
Rule of thumb: catch the specific exception (IOException, NumberFormatException) when you know what can go wrong. Catch generic Exception as a backstop.
2. Reading files — BufferedReader
try {
FileReader fr = new FileReader("data.txt");
BufferedReader br = new BufferedReader(fr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
}
catch (IOException e) { e.printStackTrace(); }
readLine() returns null at end of file
- Always
close() when done
- Requires
import java.io.*;
3. Writing files — BufferedWriter
try {
FileWriter fw = new FileWriter("out.txt");
BufferedWriter bw = new BufferedWriter(fw);
bw.write("Hello\n");
bw.write("World\n");
bw.close(); // flushes buffer
}
catch (IOException e) { e.printStackTrace(); }
new FileWriter("f.txt") — overwrites
new FileWriter("f.txt", true) — appends
- BufferedWriter holds writes in memory;
close() flushes
4. Date types — java.time
| LocalDate | date only (YYYY-MM-DD) |
| LocalTime | time only (HH:mm:ss) |
| LocalDateTime | both together |
LocalDate today = LocalDate.now();
LocalTime time = LocalTime.now();
LocalDateTime stamp = LocalDateTime.now();
today.getYear(); // 2026
today.getMonthValue(); // 1-12
today.getDayOfMonth();
today.getDayOfWeek(); // WEDNESDAY
5. DateTimeFormatter — format & parse
DateTimeFormatter fmt =
DateTimeFormatter.ofPattern("MM/dd/yyyy");
// date → string
String s = today.format(fmt);
// string → date
LocalDate d = LocalDate.parse("04/15/2026", fmt);
| y / yyyy | year |
| M / MM / MMM / MMMM | month |
| d / dd | day of month |
| E / EEEE | day of week |
| H / HH | hour (0-23) |
| m / mm | minute |
| s / ss | second |
| a | AM/PM |
Watch out: MM = month, mm = minute. Easy mix-up.
6. ArrayList
import java.util.ArrayList;
ArrayList<String> kids = new ArrayList<>();
kids.add("Ezra"); // append
kids.add(0, "Ian"); // insert at index
kids.get(0); // "Ian"
kids.set(0, "Eli"); // replace
kids.remove(0); // shifts others down
kids.size(); // count
kids.clear(); // empty it
Collections.sort(kids);
- Dynamic size — grows as you add
- Access by index with
get(i), not [i]
- Only stores objects — use
Integer not int
7. HashMap
import java.util.HashMap;
HashMap<String, String> states = new HashMap<>();
states.put("TX", "Austin");
states.get("TX"); // "Austin"
states.get("OK"); // null (not found)
states.containsKey("TX"); // true
states.remove("TX");
states.size();
Iterating
for (String v : states.values()) { ... }
for (String k : states.keySet()) { ... }
for (Map.Entry<String,String> e : states.entrySet()) {
e.getKey(); e.getValue();
}
Null danger: get(key) returns null for missing keys. Always check before using the result.
8. ArrayList or HashMap?
- ArrayList: need to preserve order, iterate in sequence, or access by position (0, 1, 2…)
- HashMap: need to find items by a unique key (id, SKU, username)
Quick test: can I ask "given X, find Y"? If yes → HashMap. Otherwise → ArrayList.
| list of students | ArrayList |
| employee by id | HashMap |
| log of events | ArrayList |
| state → capital | HashMap |
9. Agile — the basics
- Waterfall: plan once, build once, ship once. Hard to adapt.
- Agile: plan → build → ship, every 2-3 weeks. Repeat.
- Scrum is one Agile framework. Others: Kanban, XP.
Scrum roles
- Product Owner — prioritizes the backlog
- Scrum Master — facilitates, removes blockers
- Dev Team — builds the increment
Scrum events
- Sprint Planning — day 1 of the sprint
- Daily Standup — 15 min each morning
- Sprint Review — demo on the last day
- Retrospective — reflect and improve
10. User Stories
As a [role], I want [action],
so that [benefit].
- Role = a real user (customer, admin, store owner — not a developer)
- Action = something they want to do in the product
- Benefit = why it matters (the "so that")
Not a user story: "As a developer, I want to set up the project structure…" That's a technical task. Keep user stories for real users.
11. GitHub Project Board
- Columns:
Todo → In Progress → QA / Testing → Done
- New cards go into Todo (the backlog)
- Move to In Progress when you start
- QA/Testing = reviewed by someone else
- Done = verified and shipped
Limit work in progress. Focus on finishing cards before starting new ones. Finishing is what delivers value.
12. MVP — Minimum Viable Product
- The smallest version of your product that a real user can use
- Ship the MVP first — don't wait for "everything"
- Collect feedback, then decide what to build next
- Reduces risk — you find out early if you're building the right thing