Quick Index
Person Type
Ball Type
Rectangle Type
Rectangle Type vs Rectangle Objects
Now let's look at
object type
. This page is very important 💡.
Person Type
😊
Yang
😇
Sally
😔
Kofi
🙂
Jiao
🤭
Yawo
😀
Bob
😁
Mary
😃
Khawla
🤫
Zada
Recall our set of nine persons (objects).
Can we generalize all of these into one general
object type
?
Person
😊
firstName
Let's define a simple object type for Person and give it one property:
firstName
-- The first name of the specific person instance/object
Ball Type
Recall our collection of many balls (objects).
Can we generalize all of these into one general
object type
?
Let's define an object type for Ball and give it these properties:
r
-- radius of ball
color
-- color of ball
Rectangle Type
Recall our collection of many rectangles (objects).
Can we generalize all of these into one general
object type
?
Let's define an object type for Rectangle and give it these properties:
width
-- width of rectangle
height
-- height of rectangle
Note that for
real
rectangle objects, "width" and "height" will
vary.
They are variables. We'll learn more about these later.
Rectangle Type vs Rectangle Objects
Here is another perspective.
We have one
"Rectangle type"
(properties width and height).
We have many rectangle objects.
Introduction To Objects With Java (Chapter 301 - Object Types and Objects)
Chapter 301 - Object Types and Objects
Object Types
Chapter Contents
Overview
Objects
Object Types
Properties
Summary
Refs
Examples
Chapter
Top
Search
TOC