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



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

" This book is great. "
.trim();
We trim the fat and are left with “This book is great.”
I trim most of the strings I deal with if a human might have provided it. No
one wants that shit at the beginning and end of the text.
that’s all, folks
There’s a lesson to be taken from this, in addition to all the String method
themselves.
Don’t write your own method for doing something, even if it seems easy, if
someone else already devoted time and energy to creating a quality one.
If you think it’s confusing to start using these methods, I can assure you it
would be even more confusing to try and write them yourself.
Chances are if you need to manipulate a String, someone else has needed to
do the same thing. In these cases, the Java Standard Library itself is giving
you the methods you need. If Java doesn’t have it built-in, use the internet
to find a good way to do it. You might be able to make your life a lot easier.
There are also ways to download “libraries” full of helpful code for you to
use, written by other members of the Java community, but that’s outside the


scope of this lil book. For now, stick to Googling and copy-pasting like the
rest us.
Concatenation
Still with me? Good.
Here’s another big confusing word. Concatenation.
Remember the plus sign? You can use it to add numbers together.
int
result =
3
+
2
;
Answer: 5
Java also uses the plus sign to let us “add”, or “concatenate” (kun-kat-en-
ate) things to Strings.
String helloWorld =
"Hello, "
+
"world!"
;
--> ”Hello, world!”
String cashRegisterDisplayStr =
"DISCHARGE "
+ change +
" IN CHANGE TO CUSTOMER"
;
--> “DISCHARGE 7.09 IN CHANGE TO CUSTOMER”
String thisIsNotTwo =
"1"
+
1
--> “11”
Note: with that last example… if you try to add two things together and one
of them is a String, they will be concatenated, not added. It’s “11”, not 2.
Okay, not too bad! One more example.
Let’s say you’re a shopping website on the interwebs. The user purchases
an item, and you want to thank them for purchasing it. Maybe you’d show
them a message like this:
String itemName =

Download 3,91 Mb.

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