from
javac -cp "./w3schools;./w3schools/garage/mypackage" -d "./build/w3schools" Main.java
java -cp "./build/w3schools" Main
- Asks for data:
- number of spots
- person name
- car brand, color
- garage spot
- Prints inputs
Used: ArrayList, inheritance, abstract class, Scanner, loop, for .. in
Classes:
- Main
- Person
- Vehicle
- Car
- GarageSpot
- Garage
- Time
- mypackage
- Main
- imports local package
- use Scanner for input
- use
- Car extends abstract class Vehicle
- brand
- color
- Person
- name
- GarageSpot
- car: Car
- owner: _Person
- spotNumber
- Garage: array of GarageSpot's
- Time
- imports
- java.time.LocalDateTime
- java.time.format.DateTimeFormatter
- returns formatted now() string
- imports
javac -d "./build/w3schools/fileHandling" "./w3schools/FileHandling.java"
java -cp "./build/w3schools/fileHandling" FileHandling
- Creates a file
- Writes to the file
- Reads from the file
- Gets file info
- Deletes the file
imports:
java.io.File
java.io.FileWriter
java.io.IOException
java.util.Scanner
javac -d "./build/w3schools/goods" "./w3schools/Goods.java"
java -cp "./build/w3schools/goods" Goods
- Creates a HashSet
- Add items to the HashSet
- Removes an item
- Iterates through the HashSet and removes an item with an iterator
imports:
java.util.Iterator
java.util.HashSet
javac -d "./build/w3schools/numbers" "./w3schools/Numbers.java"
java -cp "./build/w3schools/numbers" Numbers
- Asks for the array size
- Gets the array items with
Scanner(System.in)
- Sorts the array with
Collections.sort
- Prints original and sorted array with a static method
imports:
java.util.Scanner
java.util.ArrayList
java.util.Collections
java.util.function.Consumer
javac -d "./build/w3schools/printFormatted" "./w3schools/PrintFormatted.java"
java -cp "./build/w3schools/printFormatted" PrintFormatted
Use lamda for a string transformation and output
javac StringSearch.java
java StringSearch
User a regular expression for string search