All language subtitles for 002 Creating an Object_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Objects make your code organized and easier to understand.

Object oriented programming means organizing your code around objects.

And the purpose of object oriented programming is to write high quality code.

In this lesson, you will create two car objects.

Before we start, create a new folder.

Call it section seven.

Inside the folder, create a file named Main Java, and then make sure that your class has a main method.

So your boss wants you to write code based on these requirements.

And before you write a single line, step one is to identify the objects.

We can define what an object is based on two criterias.

An object is a thing that contains fields.

And furthermore, an object is a thing that performs tasks.

Take some time to remember these two bullet points.

Now then, how many objects can you identify from this passage?

I only count one type of object car.

So based on the first bullet point, which describes an object as a thing that contains fields, car

is a thing that contains the fields make price year end color.

Going back to our criteria, an object is also a thing that can perform tasks.

In this case, a car object can drive.

So let's keep track of our progress.

We identified one object, a car.

A car is defined by its make price year end color.

And furthermore, a car can drive.

So that was step one.

You identified one type of object car.

Step two is to create a class.

The class is a blueprint from which you can create an object.

Previously we identified that every car is defined by its make price year and color.

So based on these fields, we can create a blueprint.

Our class, our blueprint, will declare that every single car needs to define a make price year end

color.

Inside your project.

Create a new file called Car Java.

And inside the car class, we declare that every single car needs to define a make.

It needs to define a price.

A year.

And a color.

And that's all.

The car class is a blueprint, and from this blueprint we can create many car objects.

And that's actually step number three from the car class.

You will create car objects.

The object will be of type car.

Here we are creating a new object of the class.

The variable automatically stores a reference to that object.

And once I create an object, I can modify its fields.

So what we'll do when our code is from the car class, from the blueprint that we just developed, we're

going to create two car objects.

The first object will be if type car.

I will call the variable Nissan, and the Nissan variable will store a reference to a brand new object

of the car class.

This car object is automatically going to contain four fields.

We can set the first field the make equal to Nissan.

We can set its price equal to $10,000.

We can set it's year.

Equal to 2020.

And we can set its color.

Be equal to green.

Let's visualize the runtime.

Here we are creating a new object of the car class and the variable Nissan stores a reference to that

object.

And the object is fields by default are going to start at zero or null.

Here we update that object as make to Nissan.

Here we update it's priced at $10,000.

Here we update that object says year to 2020.

And here we update this object as color to green.

And how easy was that?

Using the same blueprint, I can create another object of the car class.

I will call this variable dodge.

And the Dodge variable will store a reference to a brand new object of the car class.

This brand new car object is going to have a make that equals dodge.

It's going to have a price that equals 11,000.

It's going to have a year.

Of 2019.

And it will have a color of blue.

Before we visualize the runtime, there is a text file inside of your resources folder.

Please take some time to download it.

The file that you just downloaded contains code that prints the fields of each object.

So copy it into your main class and let us once again visualize the runtime.

Press debug.

Here we are creating a new object of the class.

This variable, Nissan automatically stores a reference to that object.

The object is fields by default start zero or null.

Here we update that object as make.

Here we update its price.

Here we update its year and here we update its color.

Here we're creating another object of the car class, and the variable dodge is going to store a reference

that points to that object.

The object is fields by default, start at zero or null, and once again, we update every single field

in that object.

At this point, we successfully created two objects of the car class, and finally, we can print the

fields of each object.

The first object, if I hover over the variable that points to it you can see, has a make of Nissan

a price of 10,000 a year of 2020 and a color of green.

So that's what's going to print.

Beautiful.

The second object, if I hover on the variable that points to it, has a make of dodge, a color of

blue, a price of 11,000 and a year of 2019.

Let's just press continue.

And that is exactly what Prince.

So to recap, you created two objects of the car class.

A car class is a blueprint from which you can create concrete car objects.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.