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



Download 17,18 Mb.
Pdf ko'rish
bet9/90
Sana22.06.2022
Hajmi17,18 Mb.
#693704
1   ...   5   6   7   8   9   10   11   12   ...   90
Bog'liq
(Head Up) Kathy Sierra Bert Bates - Head First Java, 3rd Edition Early Release-O\'Reilly Media, Inc. (2021)

can I say something like:
int x = 1; 
while (x){ }
A:
No. A 
boolean
and an 
integer
are not compatible types in Java. Since the
result of a conditional test 
must
be a boolean, the only variable you can
directly test (without using a comparison operator) is a 
boolean.
For
example, you can say:
boolean isHot = true; 
while(isHot) { }
Example of a while loop
public class Loopy { 
public static void main (String[] args) { 
int x = 1; 
System.out.println(“Before the Loop”); 
while (x < 4) { 
System.out.println(“In the loop”); 


System.out.println(“Value of x is ” + x); 
x = x + 1; 

System.out.println(“This is after the loop”); 

}


BULLET POINTS 
Statements end in a semicolon 
;
Code blocks are defined by a pair of curly braces 
{ }
Declare an 
int
variable with a name and a type: 
int x;
The 
assignment
operator is 
one
equals sign 
=
The 
equals
operator uses 
two
equals signs 
==

while
loop runs everything within its block (defined by curly
braces) as long as the 
conditional test
is 
true
.
If the conditional test is 
false
, the 
while
loop code block won’t
run, and execution will move down to the code immediately
after
the loop block.
Put a boolean test inside parentheses: 
while

Download 17,18 Mb.

Do'stlaringiz bilan baham:
1   ...   5   6   7   8   9   10   11   12   ...   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