My hands-on code examples and small side projects as I learned Java. Starts with simple terminal inputs and loops, then moves into OOP patterns, file streams, Swing GUIs, and audio playback.
src/
├── Basics/ # Inputs, strings, math utilities, final keyword
├── arrays/ # Primitive arrays, 2D grids, ArrayLists
├── loops/ # For, while, nested, and enhanced loops
├── methods/ # Overloading and CLI calculator
├── oop/ # 13 packages covering OOP concepts
└── AdvancedJava/ # Audio player, file I/O, exceptions, Swing GUIs
UsersInput.java: Reading terminal input withScanner.StringMethods.java: Essential string operations liketrim(),replace(), andlength().PrintfAndFinalKeyword.java: String formatting viaprintfand defining constants withfinal.Factorial.java,MathTest.java,RandomNumber.java: Math calculations and random value generators.
ArraysIntro.java&Arrays2DIntro.java: Fixed 1D arrays and 2D matrices.ArrayList1.java&ArrayList2D.java: Dynamic lists that grow as elements are added.
- Loop mechanics: standard
for,while, nested grid generation, andfor-eachiterations. OverloadedMethods.java: Writing methods with shared names but different parameters.MethodCalculator.java: Interactive command-line calculator using methods andswitchstatements.
I split OOP into 13 standalone folders so each idea stays isolated:
| Package | Focus | Key Concept |
|---|---|---|
oop1intro |
Classes & Objects | Creating blueprint classes (Car.java) |
oop2Constructors |
Constructors | Setting initial state with parameters |
oop3Scope |
Variable Scope | Field visibility: local vs. class-level |
oop4Overloadedmethods |
Constructor Overloading | Instantiating objects in multiple ways |
oop5ToString |
toString() |
Overriding toString() for readable output |
oop6ArraysOfObject |
Object Arrays | Storing instances inside standard arrays |
oop7ObjectPassing |
Passing Objects | Sending object references into methods |
oop8Inheritance |
Inheritance | Parent (Superclass) and child (Subclass) setups |
oop9SuperKeywordProject |
super Keyword |
Calling base class constructors and methods |
oop10AbstractionProject |
Abstraction | Abstract classes and interfaces (Crypto & Credit Card demo) |
oop11AccessModifiers |
Access Control | public, private, and protected scoping |
oop12Encapsulation |
Encapsulation | Protecting fields with getters and setters |
oop13DynamicPolymorphism |
Polymorphism | Overriding methods dynamically at runtime |
-
Console Audio Player (
src/AdvancedJava/AudioPlayer/)
CLI player built on the Java Sound API (Clip,AudioSystem). Supports Play, Stop, Reset, and volume adjustments in decibels. I added volume boundary checks so hardware won't distort if out-of-range values are entered.
Note: Expects amusic.wavfile in the root folder to play audio. -
Safe Division & Exception Handling (
src/AdvancedJava/ExceptionHandling/)
CatchesArithmeticException(divide-by-zero) andInputMismatchExceptiongracefully, usingfinallyblocks to guaranteeScannercleanup. -
File Read & Write (
src/AdvancedJava/FileHandling/)
Reads and writes.txtfiles usingFileReader,FileWriter, andtry-with-resourcesfor auto-closing file handles. -
Swing Desktop Interfaces (
src/AdvancedJava/GUI/)
Desktop UI layouts (BorderLayout,GridLayout,LayeredPane) and controls like buttons, sliders, file choosers, and progress bars.
- Clone the repo:
git clone https://github.com/Beratfkl/java-core-fundamentals.git
- Open in IntelliJ IDEA, Eclipse, or VS Code (JDK 17 or higher).
- Run any file with a
mainmethod (MethodCalculator.java,AudioPlayer/Main.java, etc.).
Written by Berat while working through core Java fundamentals and OOP principles.