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



Download 3,91 Mb.
Pdf ko'rish
bet26/70
Sana02.04.2022
Hajmi3,91 Mb.
#524999
1   ...   22   23   24   25   26   27   28   29   ...   70
Bog'liq
Java for Fucking Idiots

'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
, … };
Yes, I got tired of typing. Those three dots (…) don’t mean anything. But do
you see what I did there?
Inside curly brackets 
{}
(or braces, whatever you call them) I put all the
chars, separated by commas. This is how arrays work, basically.
First, you put your variable type (
int, char, double
, etc.), followed by some
square brackets [].
Then, if you know the values that go in your array when it’s created, then
you can put them in the curly brackets 
{}
.


More examples:
int
[] favoriteNumbers = {
6
,
9
,
420
};
double
[] doubleDoubles = {
1.7
,
340.4
};
float
[] whyUseFloats = {
50.8f
,
129.3f
,
603.432f
};
Cool? Cool.
Making an empty box
That works when we know right away what goes in the array.
However, what if we don’t know right away all the values that go in the
array? Say that three times fast….
Scenario: I want to collect the user’s top 10 favorite letters of the alphabet.
They’re going to type them in one at a time, and I want to keep track of
everything they’ve entered. What do I do?!
Do I call it quits? Do I go home? Well, I’m already at home… so, no.
Nonsense! I can do this:
char
[] userFavoriteLetters =
new char
[
10
];
I know what you’re thinking.
“What the hell is that on the right side?
You’re supposed to use those… curly brace things when you put the
variables in the box!
And they’re letters, not numbers? What’s the 10 for?? And what does ‘new’
mean????”
Calm down, Jennifer. I can explain:

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   22   23   24   25   26   27   28   29   ...   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