— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet516/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   512   513   514   515   516   517   518   519   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

API
558
 
chapter 16
HashSet
Set
extends
implements
implementation class
interface
KEY
Collection
(interface)
Set
(interface)
List
(interface)
SortedSet
(interface)
Map
(interface)
SortedMap
(interface)
 LinkedList
Vector
 TreeSet
 LinkedHashSet
 HashSet
 ArrayList
 TreeMap
 Hashtable
 LinkedHashMap
 HashMap
The Collection API (part of it)
Notice that the Map interface doesn’t 
actually extend the Collection interface
but Map is still considered part of the 
“Collection Framework” (also known 
as the “Collection API”). So Maps are 
still collections, even though they don’t 
include java.util.Collection in their 
inheritance tree.
(Note: this is not the complete
collection API; there are other
classes and interfaces, but 
these are the ones we care
most about.)
Maps don’t extend from 
java.util.Collection, but 
they’re still considered 
to be part of the 
“collections framework” 
in Java. So a Map is 
still referred to as a 
collection.


collections 
with 
generics
you are here
4
559
We added on to the Jukebox to put the songs in a HashSet. (Note: we left out some 
of the Jukebox code, but you can copy it from earlier versions. And to make it easier 
to read the output, we went back to the earlier version of the Song’s toString() 
method, so that it prints only the title instead of title and artist.)
Using a HashSet instead of ArrayList
import java.util.*;
import java.io.*;
public class Jukebox6 { 
ArrayList songList = new ArrayList(); 
// main method etc.
public void go() { 
getSongs(); 
System.out.println(songList);
Collections.sort(songList);
System.out.println(songList);


Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   512   513   514   515   516   517   518   519   ...   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