CS & Programming · Guide

Java Zero to Hero — A Beginner's Guide

Core Java concepts with real examples — ideal for students preparing for AP CS or a first SWE role.

Overview

This guide takes you from zero Java experience to building a real working project over 10 weeks. It is designed for students preparing for AP Computer Science A, college freshmen in their first CS course, or anyone targeting a junior software engineering role where Java is required.

Java is more structured than Python — it is statically typed, compiled, and more verbose. That might sound like a downside, but it is actually a strength for learning. Java forces you to think clearly about types, structure, and design. If you understand Java well, picking up other languages becomes much easier.

Who This Guide Is For

  • High school students taking AP Computer Science A
  • College students in introductory CS courses (CS 101/CS 1)
  • Career changers targeting backend or Android development roles
  • Anyone who wants a solid foundation in a strongly typed, object-oriented language

Java vs. Python — What to Expect

If you have already learned Python, Java will feel stricter at first. Every variable needs a declared type. Every program lives inside a class. You compile before you run. These constraints feel annoying early on, but they teach you habits that make you a stronger programmer in any language.


The 10-Week Curriculum

Week 1 — Setup, Hello World, Variables, and Data Types

Goal: Get your tools installed and write your first Java programs.

Topics:

  • Installing the JDK (Java Development Kit) — use JDK 17 LTS or newer
  • Setting up IntelliJ IDEA (Community Edition is free and excellent)
  • Understanding the structure of a Java program: public class, main method
  • Primitive data types: int, double, boolean, char
  • Reference type: String
  • Declaring and initializing variables
  • System.out.println() — printing output
  • Basic arithmetic operators

Practice Exercises:

  1. Write a Hello World program. Then modify it to print your name.
  2. Declare variables for your name (String), age (int), height in feet (double), and whether you own a pet (boolean). Print each one.
  3. Calculate and print the area and perimeter of a rectangle given its width and height.
  4. What happens if you try to assign a decimal value to an int? Try it and read the compiler error.

Week 2 — Control Flow: If/Else and Loops

Goal: Make your programs branch and repeat.

Topics:

  • if, else if, else
  • Comparison operators and logical operators (&&, ||, !)
  • while loops
  • for loops
  • do-while loops
  • break and continue
  • switch statements (intro)

Practice Exercises:

  1. Write a program that reads an integer and prints whether it is positive, negative, or zero
  2. Print all even numbers from 1 to 50 using a for loop
  3. Write a number guessing game: the program picks a number (hardcode it for now), the user guesses, and the program says "too high," "too low," or "correct"
  4. Use a while loop to sum all integers from 1 to 100 and print the result
  5. Print a multiplication table for numbers 1 through 10

Week 3 — Methods and Scope

Goal: Write organized, reusable code using methods.

Topics:

  • Defining methods with a return type, name, and parameters
  • void methods vs. methods that return a value
  • Method overloading (same name, different parameters)
  • Variable scope: local vs. instance
  • Passing arguments by value
  • The static keyword (intro — why main is static)
  • Writing and calling helper methods

Practice Exercises:

  1. Write a method int add(int a, int b) and call it from main
  2. Write a method boolean isEven(int n) that returns true if n is even
  3. Write a method double celsiusToFahrenheit(double c) and test it with several values
  4. Overload a greet method: one version takes just a name, another takes a name and a time of day ("Good morning, Parth!")
  5. Refactor your guessing game to use at least two separate methods

Week 4 — Arrays and ArrayLists

Goal: Store and work with collections of data.

Topics:

  • Declaring and initializing arrays
  • Accessing elements by index
  • Iterating with for and enhanced for (for-each)
  • Array length
  • Common array problems: min, max, sum, average
  • Introduction to ArrayList<T>
  • Adding, removing, and accessing elements in an ArrayList
  • When to use an array vs. an ArrayList

Practice Exercises:

  1. Create an array of 5 integers and print their sum and average
  2. Write a method that takes an int[] and returns the largest value
  3. Write a method that reverses an array and prints the result
  4. Create an ArrayList<String> of your three favorite books. Add two more, remove one, and print the final list.
  5. Write a program that stores 10 grades in an ArrayList and prints how many are passing (>= 60)

Week 5 — OOP: Classes, Objects, and Constructors

Goal: Model real-world things as objects using classes.

Topics:

  • What a class is and how it differs from a primitive
  • Instance variables (fields)
  • Constructors: default and parameterized
  • this keyword
  • Getters and setters (encapsulation)
  • Creating objects with new
  • The toString() method

Practice Exercises:

  1. Create a Car class with fields: make, model, year. Add a constructor and a toString() method. Instantiate three cars and print them.
  2. Create a BankAccount class with a balance, and methods deposit(double amount), withdraw(double amount), and getBalance()
  3. Create a Student class with name, id, and gpa. Add a method isHonors() that returns true if GPA >= 3.5
  4. Create an ArrayList<Student> with five students and print only those on the honors list

A note on the AP exam. As of the 2025-26 Course and Exam Description, AP Computer Science A covers four units — Using Objects and Methods, Selection and Iteration, Class Creation, and Data Collections. Inheritance, polymorphism, interfaces and abstract classes are no longer examined. Weeks 6 and 7 are kept in this guide because they matter for college coursework and real engineering work, not because the exam asks for them.

Week 6 — Inheritance and Polymorphism

Goal: Build class hierarchies and write flexible code.

Topics:

  • What inheritance is and when to use it
  • extends keyword
  • Superclass and subclass
  • Method overriding and @Override
  • super keyword — calling the parent constructor and methods
  • Polymorphism: a subclass object assigned to a superclass reference
  • The Object class and its methods

Practice Exercises:

  1. Create an Animal class with a speak() method. Create Dog and Cat subclasses that override speak() with appropriate sounds.
  2. Create a Shape class with a getArea() method. Create Circle and Rectangle subclasses that implement it correctly.
  3. Store a Dog and a Cat in an ArrayList<Animal> and call speak() on each using a loop. Observe how polymorphism works.
  4. Override toString() in your Student class from Week 5 and verify it prints correctly when passed to System.out.println()

Week 7 — Interfaces and Abstract Classes

Goal: Design more flexible and modular code.

Topics:

  • What an interface is and why it is different from a class
  • Implementing an interface with implements
  • Interfaces as contracts
  • Abstract classes: when to use them instead of interfaces
  • The abstract keyword
  • Multiple interface implementation
  • Common built-in interfaces: Comparable<T>, Runnable (intro)

Practice Exercises:

  1. Create a Printable interface with a printInfo() method. Have your Student and Car classes implement it.
  2. Create an abstract class Vehicle with an abstract method getFuelType(). Create ElectricCar and GasCar subclasses.
  3. Make your Student class implement Comparable<Student> so students can be sorted by GPA. Use Collections.sort() to test it.
  4. Explain in a comment in your code: when would you choose an interface vs. an abstract class?

Week 8 — Exception Handling and File I/O

Goal: Write robust programs that handle errors and persist data.

Topics:

  • What exceptions are: checked vs. unchecked
  • try, catch, finally
  • Throwing exceptions with throw
  • Common exceptions: NullPointerException, ArrayIndexOutOfBoundsException, NumberFormatException
  • Reading files with Scanner and FileReader
  • Writing files with PrintWriter and FileWriter
  • The IOException and handling it properly

Practice Exercises:

  1. Write a program that reads integers from the user until they enter "quit" — handle NumberFormatException for invalid input
  2. Write a program that reads a text file line by line and prints each line with a line number
  3. Write a program that takes a list of students (from Week 5) and saves them to a CSV file
  4. Add file-save functionality to your BankAccount from Week 5 so transactions are logged

Week 9 — Collections: HashMap, HashSet, LinkedList

Goal: Use the right data structure for the job.

Topics:

  • Review of ArrayList — time complexity basics (why it matters)
  • HashMap<K, V>: storing key-value pairs, put(), get(), containsKey(), iterating
  • HashSet<T>: unique elements, add(), contains(), set operations
  • LinkedList<T>: intro, when it beats ArrayList
  • Iterating with Iterator and enhanced for loops
  • The Collections utility class: sort(), reverse(), frequency()

Practice Exercises:

  1. Write a word frequency counter using a HashMap<String, Integer> — given a sentence, count how many times each word appears
  2. Write a program that finds all duplicate values in a list using a HashSet
  3. Build a simple phone book using a HashMap<String, String> (name → phone number) with add, lookup, and delete operations
  4. Sort your ArrayList<Student> by name using Collections.sort() (requires Comparable from Week 7)

Week 10 — Mini Project Week

Goal: Build one complete, working Java application.

Suggested Projects (pick one):

  • Student Grade Tracker: Add/remove students, record grades, compute averages, save to and load from a file
  • Simple Inventory System: Track products with name, quantity, and price; support add, remove, search, and total-value calculations; persist data to a file
  • Library Catalog: Manage a collection of books, mark them as checked out or available, search by title or author

What Your Project Should Include:

  • At least two classes (beyond main)
  • At least one interface or abstract class
  • A collection (ArrayList or HashMap)
  • File I/O (save and load)
  • Exception handling
  • A menu-driven command-line interface

Steps:

  1. Write out your program's features in plain English before writing any code
  2. Design your classes on paper first — what fields and methods does each need?
  3. Build the simplest version first, then add features
  4. Test each class independently before wiring them together

Resources

Official and Core

Practice Platforms

AP Computer Science A Specific


A Note on Java's Verbosity

Java feels like a lot of typing compared to Python. That is intentional. When you declare ArrayList<Student> students = new ArrayList<>();, every word is meaningful: the type, the generic parameter, the constructor call. Over time, that explicitness becomes an asset — you always know what type you are working with, and the compiler catches entire categories of bugs before your program even runs.

If you are learning Java for AP CS A, stick closely to the topics on the College Board's curriculum list. If you are learning for a job, pay extra attention to Weeks 5-9 — OOP, collections, and file I/O are where most of your real work will happen.


Written by Parth Shah. For tutoring inquiries, visit ajconsultation.com.

Download this guide as a PDF Free, no email required.
Taking AP Computer Science A? This is the Java exam — see what the 2025-26 syllabus actually covers.