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


class Book { } Neat! Mission accomplished. In fact, you could even do this: class



Download 3,91 Mb.
Pdf ko'rish
bet9/70
Sana02.04.2022
Hajmi3,91 Mb.
#524999
1   ...   5   6   7   8   9   10   11   12   ...   70
Bog'liq
Java for Fucking Idiots

class
Book {
}
Neat! Mission accomplished.
In fact, you could even do this:
class
Book {}
Java doesn’t care about you pressing the enter key (creating a new line) or
pressing the space bar (creating whitespace).
In general, though, you don’t put curly braces on the same line like that,
though. There’s no real estate market in Java land, so you can take up the
space you need to make your code readable.
But congratulations, you have a class. Proud of you!


Oh, one more thing: they are always capitalized like that. If it needs to be
more than one word, you capitalize the first letter of those words and smush
them together. For example:
class
FantasyNovel {
}
Properties
Okay, so we have a basic class declared.
However, classes are pretty useless when they’re empty like that. Let’s add
property .
class
Book {
String
title
;
}
What would properties be in the real world? No, not the Monopoly kind of
properties. Let’s ask the dictionary.
Property: “an essential or distinctive attribute or quality of a thing.”
Yep. That’s about right in Java too.
We call 
title
a property because it pertains to a class. It’s the book’s name. It
doesn’t exist without the book. We can add some more properties:
class
Book {
String
title
;
String
content
;
String[]
chapterNames
;
int
bookmarkedPage
;
double
averageRating
;
boolean
hasSequel
;
Author
author
;
}


The book has a title, its actual content, chapter names… a number
representing the page that the reader bookmarked… a rating to show in a
store…
Anyway, starting to get the big idea? A class can have information
associated with it called properties.
And just to remind you – those properties will be specific to each object
created from this class. I could create 500 books, and they’d each have a
different 
title
property. I’d also probably write a good one, eventually.
Reading and writing 101
In Java, you can interact with those properties using a period. It’s called
“dot notation.”
Let’s say I have an instance of the Book class called 
bestBook
. This is an
actual Book object , created from the Book class.
Here’s how I could play around with its properties.
bestBook.

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   5   6   7   8   9   10   11   12   ...   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