— Scott McNealy, Sun Microsystems Chairman, President and ceo


boolean rem ove(Object e



Download 40,57 Mb.
Pdf ko'rish
bet200/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   196   197   198   199   200   201   202   203   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

boolean rem
ove(Object e
lem)
boolean cont
ains(Object e
lem)
boolean isEm
pty()
int indexOf(O
bject elem)
Object get(in
t index)
boolean add
(Object elem
)
// more


interfaces and 
polymorphism
you are here
4
209
So what’s in this ultra-super-megaclass Object?
Object
boolean equals()
Class getClass()
int hashCode()
String toString()
If you were Java, what behavior would you want every 
object to have? Hmmmm... let’s see... how about a 
method that lets you fi nd out if one object is equal 
to another object? What about a method that can 
tell you the actual class type of that object? Maybe a 
method that gives you a hashcode for the object, so 
you can use the object in hashtables (we’ll talk about 
Java’s hashtables in chapter 17 and appendix B). 
Oh, here’s a good one—a method that prints out a 
String message for that object. 
And what do you know? As if by magic, class Object 
does indeed have methods for those four things. 
That’s not all, though, but these are the ones we 
really care about.
Just SOME of the methods 
of class Object.
Dog a = new Dog();
Cat c = new Cat();

if (a.equals(c)) {
System.out.println(“true”);
} else {
System.out.println(“false”);
}
equals(Object o)
1
Cat c = new Cat();
System.out.println(c.getClass());
getClass()
2
File Edit Window Help Stop
% java TestObject
false
File Edit Window Help Faint

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   196   197   198   199   200   201   202   203   ...   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