Build useful Java programs with lists, maps, your own classes, exceptions and files.
- 28 lessons
- 7 units
- 4 h 41 m in all
- £0, for good
what’s inside.
For people who finished Level 1, or can already write small programs with variables, decisions, loops and functions.
Java Level 2 picks up where Level 1 ended and puts your skills to work on small, real programs. In 28 lessons you master lists, maps and sets, design classes with constructors, inheritance and interfaces, handle errors with exceptions, and save your work in files. It ends with a level check: a little library app that lends books and keeps them safe in a file.
every lesson goes the same way.
- meet it
- guess first
- your turn
- fix it
- nailed it
unit 1
Lists that grow
Keep as many things as you like, in order, and change them as you go.
unit 2
Maps and sets
Look things up by name and keep every value only once.
- Look it up with a HashMap9 minStore values under names and find them in a flash.
- Updating a map10 minChange values, check keys and count things with a map.
- Looping over a map10 minVisit every pair in a map, in sorted order when you want it.
- No repeats with a HashSet9 minKeep each value only once and check for it fast.
unit 3
Build better objects
Give your objects a proper start, skills of their own and some privacy.
- Constructors10 minBuild an object with its fields filled in from the start.
- Objects that do things10 minGive your objects methods that use their own fields.
- Keep your fields private10 minProtect an object's fields so they only change safely.
- Objects that describe themselves9 minChoose what appears when you print an object.
unit 4
Shared, equal and fixed
Share values across objects, compare them fairly and fix a set of choices.
- Shared boxes and constants10 minKeep one value for a whole class, and lock values that never change.
- When are two objects equal?12 minTeach Java when two of your objects count as the same.
- Enums: a fixed set of choices9 minList every possible choice, so typos cannot sneak in.
- Enums with their own values10 minGive each choice its own data, and turn text into a choice.
unit 5
Family trees
Build new classes on top of old ones and give them a shared shape.
unit 6
When things go wrong
Catch problems, throw your own and keep your program running.
- Catching an exception10 minHandle a problem and keep your program running.
- More catches and finally10 minHandle different problems differently, and always tidy up.
- Throwing your own problems10 minRefuse bad values loudly with throw.
- Checked exceptions and your own12 minMake your own exception and make callers deal with it.
unit 7
Save your work
Build text, save it in files and read it back.
- Building text with StringBuilder9 minBuild long text piece by piece, without waste.
- Writing and reading a file11 minSave text in a file and read it back.
- One line per record11 minSave a list as lines and turn lines back into data.
- Try-with-resources12 minOpen a file, use it and let Java close it for you.