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


"LMNOPQ" .substring( 2 , 5 ); //"B" "ABCDEFG"



Download 3,91 Mb.
Pdf ko'rish
bet56/70
Sana02.04.2022
Hajmi3,91 Mb.
#524999
1   ...   52   53   54   55   56   57   58   59   ...   70
Bog'liq
Java for Fucking Idiots

"LMNOPQ"
.substring(
2
,
5
);
//"B"
"ABCDEFG"
.substring(
1
,
2
);
//"WH"
"WHAT"
.substring(
0
,
2
);
//"" (empty string)
"GAWRSH"
.substring(
1
,
1
);
Hopefully you’re beginning to comprehend this.
One more thing to mention here. You know how we give the start index and
end index?
Well, Java lets you only give the start index, if you want. The result? You
only make one cut, and Java gives you the entire tail end of the String.
//"Cool"
"Lame Cool"
.substring(
5
);
//"BCDEFGHIJKLMNOP"
"ABCDEFGHIJKLMNOP"
.substring(
1
);
RIP in pieces “A”
split
I like this method. It creates a bunch of smaller Strings out of your String.
You give Java a character to “split” on. The string is karate chopped at each
occurrence of that character. You’re left with an array of the results.
String sentence =
"I just think they’re neat"
;
String[] words = sentence.split(
" "
);
Guess what? We now have an array of the words! That’s 5 items in the
array!


{
"I"
,
"just"
,
"think"
,
"they're"
,
"neat"
}
When Java saw an empty space, it dropped a tactical missile and split the
String up. The bits to the left and right ended up in the array.
Freaking nice right there.
trim
Okay, last one. That I’m going to mention…there’s a few more. But this
one’s easy.
It removes all the empty whitespace and newlines from beginning and end
of your String.

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   52   53   54   55   56   57   58   59   ...   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