A Peek at Java …
Java is all about objects. A Java object is little bundle of data and code that typically represents a thing, possibly something in the real world like a book but possibly something more abstract like a stack or a queue. The data in objects is organized as fields, named values attached to the object. So an object that represents a book might have fields called title and author.
Every Java object is associated with a class. It’s an object’s class that determines exactly which fields and which methods the object carries. Classes typically also specify a constructor, a special bit of code that gets called when a new object is created. It’s the constructor that initializes the fields on an object and otherwise gets it ready to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access