Stage 1 · Lesson 9 of 9
Packages and reading files
Once a program has several classes, group them in . Put a line such as package com.ada.budget; at the top of each file, with folders to match. Use import to bring in classes from other packages or the .
For , use java.nio.file. Files.readAllLines(Path.of("data.csv")) returns a List<String>, one item per line, and Files.lines streams the lines one by one for large files. Both throw IOException, which you must handle.
are worked out from the folder where you ran java. That is a frequent reason for "file not found". Split each line, turn the fields into numbers with Integer.parseInt or Double.parseDouble, and build objects from them. That is the core of the milestone.
A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CourseFreeJava Programming MOOC
University of Helsinki · Beginner
Free Helsinki course with hundreds of auto-tested exercises; parts 1 to 8 cover this stage
- GuideFreeDev.java: Learn Java
Oracle · Beginner
Official tutorials from the Java team: read the language basics path next to the MOOC