Loading…
Loading…
Topic
Articles and problems tagged Object-Oriented Programming.
Write your first real Java class: an Employee with private fields, a constructor and methods. Covers multiple classes and source files, how javac finds dependencies, constructor rules, var for local variables, handling null with Objects.requireNonNull, and implicit vs. explicit parameters and this.
Learn to work with objects from the Java library: constructors and new, the difference between objects and object variables, references and null, why Java has LocalDate instead of a date type, factory methods, accessor vs. mutator methods, and a complete calendar program.
The ideas behind object-oriented programming in Java: classes and objects, encapsulation, an object's behavior, state and identity, finding classes from nouns and verbs, and the uses-a, has-a and is-a relationships between classes with UML notation.
Sort and search arrays with java.util.Arrays, draw raffle winners without repeats, generate random numbers the modern way, build tables with two-dimensional arrays, and understand Java's arrays of arrays: deepToString, swapping rows, and ragged (triangular) arrays.
One-dimensional Java arrays: declaring and creating arrays, initializers and anonymous arrays, default values, indexes and ArrayIndexOutOfBoundsException, the enhanced for-each loop, printing with Arrays.toString, reference vs. value copying with Arrays.copyOf, and command-line arguments.
Repeat work in Java with while, do-while and for loops: how each one tests its condition, a savings-target calculator, counting team combinations, counting down, the scope of loop variables, floating-point loop traps, infinite loops, and how to choose the right loop.
How + - * / % behave in Java, why 15 / 2 is 7, how remainder works with negative numbers, when to use Math.floorMod and floorDiv, the most useful Math methods (pow, sqrt, round, clamp…), overflow-safe exact methods, and StrictMath.
Process annotations at the bytecode level: the class file format, javap, CLASS-retention annotations, inserting logging code with ASM's AdviceAdapter, the new Class-File API, and rewriting classes at load time with a Java agent and ClassFileTransformer.
Why Java streams exist and how they differ from collections and loops: the "what, not how" style, lazy evaluation, the three stages of a pipeline (source, intermediate, terminal), single-use streams and a first look at parallel streams.
A line-by-line explanation of a simple Java program: classes and naming rules, why the file name matters, what public static void main(String[] args) means, statements and method calls, print vs println, exit codes, comments, and Java 25's simpler main.