— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet86/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   82   83   84   85   86   87   88   89   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

Why did Tawny choose Bob’s method over Kent’s, when Kent’s used less memory?
Five-Minute
Mystery


68
 
chapter 3
A
B
Code Magnets:
class Books {
String title;
String author;
}
class BooksTestDrive {
public static void main(String [] args) {
Books [] myBooks = new Books[3];
int x = 0;
myBooks[0] = new Books(); Remember: We have to
myBooks[1] = new Books(); actually make the Books
myBooks[2] = new Books(); objects !
myBooks[0].title = “The Grapes of Java”;
myBooks[1].title = “The Java Gatsby”;
myBooks[2].title = “The Java Cookbook”;
myBooks[0].author = “bob”;
myBooks[1].author = “sue”;
myBooks[2].author = “ian”;
while (x < 3) {
System.out.print(myBooks[x].title);
System.out.print(“ by “);
System.out.println(myBooks[x].author);
x = x + 1;
}
}
}
class Hobbits {
String name;
public static void main(String [] args) {
Hobbits [] h = new Hobbits[3];
int z = -1; Remember: arrays start with
while (z < 2) { element 0 !
z = z + 1;
h[z] = new Hobbits();
h[z].name = “bilbo”;
if (z == 1) {
h[z].name = “frodo”;
}
if (z == 2) {
h[z].name = “sam”;
}
System.out.print(h[z].name + “ is a “);
System.out.println(“good Hobbit name”);
}
}
}
class TestArrays {
public static void main(String [] args) {
int [] index = new int[4];
index[0] = 1;
index[1] = 3;
index[2] = 0;
index[3] = 2;
String [] islands = new String[4];
islands[0] = “Bermuda”;
islands[1] = “Fiji”;
islands[2] = “Azores”;
islands[3] = “Cozumel”;
int y = 0;
int ref;
while (y < 4) {
ref = index[y];
System.out.print(“island = “);
System.out.println(islands[ref]);
y = y + 1;
}
}

File Edit Window Help Bikini

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   82   83   84   85   86   87   88   89   ...   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