
Java : Classes and Objects
Oddly Yogi · 1 lượt xem · 13 thg 11, 2026
Mô tả
How do we model real things like books and library members in Java? In this video we write our first real classes. Like a printed membership form and the filled-in cards made from it, a class describes what every object has, and each object holds its own values. We cover fields, constructors and this, creating objects with new, references and null (with Java's helpful NullPointerException messages), encapsulation with private fields, getters and validating setters, final fields, static counters and constants, overloaded constructors, flexible constructor bodies (final in Java 25), toString, packages with javac -d and java -cp, and records, which give us equals, hashCode and toString for free. Shelf gets Member, Book, Library and Main classes.
Versions: Java 25 LTS (Eclipse Temurin 25.0.5).
In this chapter:
00:00 A form and the cards made from it
01:27 Our first class: Member
03:04 Creating objects with new
04:35 Printing an object: toString
05:32 Encapsulation: private fields and setters
07:18 final fields and static members
09:34 Overloaded constructors and flexible bodies
11:33 References and null
13:11 Passing objects to methods
14:36 Records: classes that carry data
17:12 A Library that holds the books
18:42 Who can see what
19:38 static and instance methods
20:32 Wrap up
This is Chapter 3 of 15 in the "Java" series.
#Java #Java25 #Programming #LearnJava #OOP