Head First Java a brain-Friendly Guide Kathy Sierra and Bert Bates



Download 17,18 Mb.
Pdf ko'rish
bet55/90
Sana22.06.2022
Hajmi17,18 Mb.
#693704
1   ...   51   52   53   54   55   56   57   58   ...   90
Bog'liq
(Head Up) Kathy Sierra Bert Bates - Head First Java, 3rd Edition Early Release-O\'Reilly Media, Inc. (2021)

You can send things to a method
Just as you expect from any programming language, you can pass values
into your methods. You might, for example, want to tell a Dog object how
many times to bark by calling:
d.bark(3);


Depending on your programming background and personal preferences, 
you
might use the term 
arguments
or perhaps 
parameters
for the values passed
into a method. Although there 
are
formal computer science distinctions that
people who wear lab coats and who will almost certainly not read this book,
make, we have bigger fish to fry in this book. So 
you
can call them
whatever you like (arguments, donuts, hair-balls, etc.) but we’re doing it
like this:
A method uses parameters. A caller passes arguments.
Arguments are the things you pass into the methods. An 
argument
(a value
like 2, “Foo”, or a reference to a Dog) lands face-down into a... wait for it...
parameter
. And a parameter is nothing more than a local variable. A
variable with a type and a name, that can be used inside the body of the
method.
But here’s the important part: 
If a method takes a parameter, you must
pass it something.
And that something must be a value of the appropriate
type.


You can get things back from a method.
Methods can return values. Every method is declared with a return type, but
until now we’ve made all of our methods with a 
void
return type, which
means they don’t give anything back.
void go() {
}
But we can declare a method to give a specific type of value back to the
caller, such as:

Download 17,18 Mb.

Do'stlaringiz bilan baham:
1   ...   51   52   53   54   55   56   57   58   ...   90




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