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


"MEMES" .equalsIgnoreCase( "memes"



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

"MEMES"
.equalsIgnoreCase(
"memes"
);
contains
For when you want to see if there’s a particular String inside your String.
Maybe you’re Mark Zuckerberg and want to see if a user’s Facebook post
contains “vaccines”.
//true
"Boy am I glad that vaccines were invented"
.contains(
"vaccines"
);
Note that 
contains
is case sensitive. That means it cares about if the
characters are uppercase or lowercase. i.e.
//false
"BOy I HatE HoW VACccINeS CauSe AUTisM!"
.contains(
"vaccines"
);


Hmm. How can we see if “vaccines” is inside there, no matter what case the
letters are in? I know! We’ll use containsIgnoreCase !
Just kidding – doesn’t exist! Dammit Java.
There’s one easy way to do to this for 99.9% of scenarios. It involves our
next superpower, so we’ll go over it first.
toLowerCase and toUpperCase
String bestGame =
"Old School Runescape"
;
//"OLD SCHOOL RUNESCAPE"
String bigBoy = bestGame.toUpperCase();
//"old school runescape"
String lilBoi = bestGame.toLowerCase();
Extremely straightforward. Just changes letters to either the upper- or
lower-case versions.
The people who wrote those methods? 
Not as straightforward for them
 .
containsIgnoreCase? Remember? Hello?
Ah, right! Okay, first, you just standardize what case the letters are in. Then
you can do contains .
String testString =
"BOy I HatE HoW VACccINeS CauSe AUTisM"
;
//"boy i hate how vaccines cause autism"
testString = testString.toLowerCase();
//true
testString.contains(
"vaccines"
);
If you really wanted to, you could instead change it toUpperCase and look
for “VACCINES”.
charAt


Remember “indexes” from arrays? You know, [0] gets the first element, [1]
gets the second element, and so on? Well that knowledge, unfortunately for
you, is coming back from the dead for this exercise.

Download 3,91 Mb.

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