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



Download 3,91 Mb.
Pdf ko'rish
bet51/70
Sana02.04.2022
Hajmi3,91 Mb.
#524999
1   ...   47   48   49   50   51   52   53   54   ...   70
Bog'liq
Java for Fucking Idiots

class
Airplane {
void
fly() {
fly(currentAltitude);
}
void
fly(
int
altitude) {
fly(altitude, currentSpeed);
}
void
fly(
int
altitude,
double
speed) {
//The actual code to fly

}
}


See how they’re calling each other? This is an example of how you can
reuse your code without copy pasting!!!! It’s like a chain or something.
Just want to start flying? Call 
fly
and it will use the current altitude. Want to
change the altitude? It will 
fly
to that altitude with the current speed. Want
to change both? Call the full fly method.
Method to the Madness
Objects in Java do shit all the time. That’s why we write code after all; the
program needs to do something valuable for us humans.
Methods are helpful for more than just doing things on behalf of the object;
they also let us programmers turn a confusing mess of spaghetti into a
reasonable chunk of code.
For example, remember Eugene? Do you think Eugene has just one method
to perform his translation?
Under the hood, that 
translate
method could have been doing a whole litany
of things:
String translate(String textToTranslate) {
cleanseInput(textToTranslate);
parseWords();
translateWords();
adjustPunctuation();

return
translation
;
}
Much better than a 1000-line method of the noodle variety.
Divide your methods up to prevent method madness.


CHAPTER 11: STRINGS
 
String theory.
A theoretical framework in which the point-like particles of particle physics
are replaced by one-dimensional objects called strings.
My string theory is that Strings in Java are the best variable type of all time.
ALL TIME!
What’s a string?
You’ve seen ‘em. I’ve talked about ‘em. You probably have a general idea
of what they are by now.
It’s just some text, right? “abc” or “23890chusoao”? Aren’t those Strings?
Yep. The double quotes “ “ are what identify Strings. That or, you know…
the word String. Duh.
But Strings are super special in Java; not only are they extremely common,
they have a ton of built-in methods that make them super powerful. And
you oughtta know why Strings are the best. The kind of “oughta know” that
Alanis Morisette would advocate.
Anything that does not require math (addition, multiplication, that stuff) and
is not a boolean (true or false) value should be a string 99.9% of the time,
ISO (In Steve’s opinion)
Text
Want to represent a single character? You could use a char , right?

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   47   48   49   50   51   52   53   54   ...   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