Java from the ground up
The language that runs almost everywhere
- Beginner
- 12 chapters
- 185 min read
Learn Java by running it: the main method and printing, variables and the primitive types, text and its methods, decisions with if and switch, loops, methods with parameters and return values, arrays, ArrayList and HashMap, classes with fields and constructors, interfaces and a small hierarchy, exceptions, and a capstone that sorts records into a report.
What You'll Learn
- Write, compile and run a program that starts at main and prints a line
- Hold values in typed variables, and know what division and casting really do
- Work with text using length, charAt, substring, case changes and equals
- Branch with if, else, switch and the ternary form
- Repeat work with for, while and the enhanced for loop
- Write static methods with parameters, return values and void
- Use arrays, Arrays.toString and Arrays.sort
- Grow and key collections with ArrayList and HashMap
- Build classes with fields, constructors and methods of your own
- Implement an interface, extend a class, and let one loop serve both
- Catch failures with try and catch, and throw your own with a message
- Assemble a sorted report from a class, a HashMap and a comparator
Prerequisites
- No programming experience needed — this course starts at the first line
- Any other language you know will make the early chapters quick
Course Content
- 01Your first Java programNot started
What Java is for, the class and the main method every program starts from, and how to print a line of text on the screen.
- 02Variables and the primitive typesNot started
Giving values a name, the primitive types you will use every day, and what really happens when you divide a whole number or cast one.
- 03Text, and the String methodsNot started
Strings are objects, so they come with methods: counting characters, reading one, cutting a piece out — and why == is not equals.
- 04Decisions: if, else and switchNot started
Comparing values, joining conditions with and, or and not, choosing a path with if and else, and picking one case with switch.
- 05Loops: for, while and the enhanced forNot started
Repeating work three ways: the counted for loop, the while loop that stops on a condition, and the enhanced for that walks a whole array.
- 06Methods: parameters and return valuesNot started
Naming a piece of work, handing it values, getting an answer back, and why every method so far has been marked static.
- 07Arrays and the Arrays helperNot started
One name for many values, indexing from zero, the length that cannot change, and the helper class that makes an array readable.
- 08ArrayList and HashMapNot started
Two collections that grow as you need them: a numbered list, and a set of keyed values where a word is the address.
- 09Classes: fields, constructors and methodsNot started
A type of your own that carries data and the methods that work on it, built with a constructor and used through objects.
- 10Interfaces and a tiny hierarchyNot started
A promise a class makes to the rest of the program, a class that extends another, and the polymorphism that follows from both.
- 11Exceptions: try, catch and throwNot started
What happens when something goes wrong, how to catch it and carry on, and how to throw a problem of your own with a reason attached.
- 12Putting it together: a small reportNot started
The whole course in one file: a class for each record, a HashMap to hold them, a sort, and a printed report that anyone can read.
