— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet55/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   51   52   53   54   55   56   57   58   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

alarmTime
alarmMode
setAlarmTime()
getAlarmTime()
isAlarmSet()
snooze()
knows
does


you are here
4
classes 
and 
objects
35
What’s the difference between 

class
and an 
object

A class is a blueprint for an object. It tells the 
virtual machine how to make an object of that 
particular type. Each object made from that 
class can have its own values for the 
instance variables of that class. For 
example, you might use the Button 
class to make dozens of different 
buttons, and each button might have 
its own color, size, shape, label, and so on.
A class is not an object.
(but it’s used to construct them)
class
JVM
Look at it this way...
One analogy for objects is a packet of unused Rolodex

cards.
Each card has the same blank fields (the instance variables). When 
you fill out a card you are creating an instance (object), and the 
entries you make on that card represent its state.
The methods of the class are the things you do to a particular card; 
getName( ), changeName( ), setName( ) could all be methods for 
class Rolodex.
So, each card can do the same things (getName( ), changeName( ), 
etc.), but each card knows things unique to that particular card.
An object is like one entry in your address book.


36
 
chapter 2
class DogTestDrive {
public static void main (String[] args) {
Dog d = new Dog();

d
.

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   51   52   53   54   55   56   57   58   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish