Java for Fucking Idiots: Learn the Basics of Java Programming Without any experience!



Download 3,91 Mb.
Pdf ko'rish
bet38/70
Sana02.04.2022
Hajmi3,91 Mb.
#524999
1   ...   34   35   36   37   38   39   40   41   ...   70
Bog'liq
Java for Fucking Idiots

int
i = myArray.
length
-
1
;
2. Run the loop until we reach the beginning of the array (including
position 0)
i >=
0
;
3. Decrease the value of the index at the end of each loop iteration
i--
char
[] myArray = {
'A'
,
'B'
,
'C'
,
'D'
};
for
(
int
i = myArray.
length
-
1
; i >=
0
; i--) {
System.
out
.println(myArray[i]);
}
Try to read through that yourself a few times to understand what each part
is doing. Then I’ll spill the beans. I hate beans.
Here’s how what we’re asking Java to do in English…
1. Create an array with 4 elements, A B C D.
2. Create a variable i (the index) and set it equal to 3 to start.
3. Specify that the loop should keep going as long as i is greater or
equal to 0.
4. Specify that at the end of each loop, we should decrease the index
by 1.
And here’s how it actually runs, step by step. If you’re confused right now,
this part should help.


char
[] myArray = {
'A'
,
'B'
,
'C'
,
'D'
};
for
(
int
i = myArray.
length
-
1
; i >=
0
; i--) {
System.
out
.println(myArray[i]);
}
1. Set i to 3. This is greater than or equal to 0. Run code inside loop
(Print ‘D’). Decrease i by 1.
2. i is now 2. This is greater than or equal to 0. Run code inside loop
(Print ‘C’). Decrease i by 1.
3. i is now 1. This is greater than or equal to 0. Run code inside loop
(Print ‘B’).. Decrease i by 1.
4. i is now 0. This is greater than or equal to 0. Run code inside loop
(Print ‘a’).. Decrease i by 1.
5. i is now -1. This is not greater than or equal to 0. Loop is

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   34   35   36   37   38   39   40   41   ...   70




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