Head First Java a brain-Friendly Guide Kathy Sierra and Bert Bates


B if ( x < 3) {  System.out.println(“small x”);  }  } This file won’t compile without a  } class declaration, and don’t forget



Download 17,18 Mb.
Pdf ko'rish
bet18/90
Sana22.06.2022
Hajmi17,18 Mb.
#693704
1   ...   14   15   16   17   18   19   20   21   ...   90
Bog'liq
(Head Up) Kathy Sierra Bert Bates - Head First Java, 3rd Edition Early Release-O\'Reilly Media, Inc. (2021)

B
if ( x < 3) { 
System.out.println(“small x”); 

} This file won’t compile without a 
} class declaration, and don’t forget
} the matching curly brace !


_________________________________________________________
class Exercise1b { 
public static void main(String [] args) { 
int x = 5; 
while ( x > 1 ) { 
C
x = x - 1; 
if ( x < 3) { 
System.out.println(“small x”); 
}
} The ‘while’ loop code must be inside 
}
a method. It can’t just be 
} hanging out inside the class.
 puzzle answers
class PoolPuzzleOne { 
public static void main(String [] args) { 
int x = 0; 
while ( 
X < 4
) { 
System.out.print(“a”);
if ( x < 1 ) { 
System.out.print(“ “);

System.out.print(“n”);
if ( 
X > 1
) { 
System.out.print(“ oyster”);
x = x + 2;

if ( x == 1 ) { 
System.out.print(“noys”);

if ( 
X < 1
) { 
System.out.print(“oise”);



System.out.println(““); 
X = X + 1;


}
Free! Bonus Puzzle!
There is another way to solve the pool puzzle, that might be easier to read,
can you find it?




Chapter 2. Classes and
Objects: A Trip to Objectville
I was told there would be objects.
In 
the main() method. That’s not exactly object-oriented. In fact, that’s not
object-oriented 
at all
. Well, we did 
use
a few objects, like the String arrays
for the Phrase-O-Matic, but we didn’t actually develop any of our own
object 
types
. So now we’ve got to leave that procedural world behind, get


the heck out of main(), and start making some objects of our own. We’ll
look at what makes object-oriented (OO) development in Java so much fun.
We’ll look at the difference between a 
class
and an 
object
. We’ll look at
how objects can give you a better life (at least the programming part of your
life. Not much we can do about your fashion sense). Warning: once you get
to Objectville, you might never go back. Send us a postcard.

Download 17,18 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   ...   90




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