All language subtitles for Intro-to-Java-Programming-Course-for-Absolute-Beginners_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
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
hu Hungarian
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

Hey guys, and welcome to a brand new tutorial\xa0\n

teaching you Java from the beginning. So starting\xa0\n

how to create variables, methods, like all\xa0\n

the advanced stuff. This is a beginner tutorial\xa0\n

never learned any programming language before.\xa0\n

thing we need to do is download a ID E. And this\xa0\n

okay, so it's called Eclipse, that's what I'm\xa0\n

beginner, I recommend you just follow along with\xa0\n

are specific to eclipse. So go to this link,\xa0\n

click on download. And then obviously, 32 or 64\xa0\n

have a 64 bit machine. Once you download this,\xa0\n

but if we go to our downloads, we will see\xa0\n

double click on it, wait for this to boot up\xa0\n

let's see. And once we're in here, we're simply\xa0\n

we don't need to be using any of this other\xa0\n

so we're going to install this, I already have it\xa0\n

gonna ask you for a project directory, something\xa0\n

wherever on your computer, it doesn't really\xa0\n

you chose your project directory. Now we're going\xa0\n

we need to do so it should look something like\xa0\n

and then Java project. Now here, I'm just gonna\xa0\n

can just leave all the rest of this stuff blank.\xa0\n

click Finish. And there we are. So once we have\xa0\n

the package explorer, I'm just gonna shrink\xa0\n

is we're going to go down to source or Oh, I\xa0\n

I'm going to create a new one really quickly, and\xa0\n

one. Okay, finish. Alright, we got tutorial\xa0\n

the source, what we're going to do is we're going\xa0\n

and we're going to click on package. Now, I\xa0\n

the same as your project. So I'm going to do that\xa0\n

name, I'm going to click New, and plus. Okay, so\xa0\n

it's going to allow you to select the package and\xa0\n

the name you can name is whatever you want. In my\xa0\n

discouraged. Okay, so let's name it main with\xa0\n

like that. And then we're going to do is make sure\xa0\n

to check mark this because we're gonna need this\xa0\n

inherited abstract methods, you can uncheck\xa0\n

really matter for right now. Okay, so now we're in\xa0\n

I'm going to explain what this is. And then we'll\xa0\n

just printing a few things to the screen before\xa0\n

about data types. So Java is an object oriented\xa0\n

happens inside of something called classes, and\xa0\n

Now, you're not gonna understand very much of this\xa0\n

guys that are more advanced, you should come to\xa0\n

okay? And everything in Java is written in a\xa0\n

our purpose, just think everything is written in\xa0\n

we have a special method is what it's called. And\xa0\n

inside these curly brackets, public static, void,\xa0\n

what those words mean, just know, this method\xa0\n

writing all of our Java code in for right now. So\xa0\n

curly braces, and not inside of this method,\xa0\n

your code is not going to execute properly unless\xa0\n

we don't yet. So all the code we're writing goes\xa0\n

these curly braces. All right. Now the first\xa0\n

something to the screen. So to print something\xa0\n

computer's lagging one second dot print, ln,\xa0\n

now inside of these brackets here, we can print a\xa0\n

in Java is anything encapsulated by two quotation\xa0\n

we want to do it in two quotation marks, at least\xa0\n

the classic hello world with an exclamation point,\xa0\n

Java But with exception of lines that start or end\xa0\n

now you can see once I put the semicolon, that\xa0\n

we can see that it now has syntax highlighting. In\xa0\n

the program. So we have to make sure that whenever\xa0\n

a semicolon. Okay, so now we've officially written\xa0\n

to the screen, but how can we run this. So first,\xa0\n

S. And to run this, there's a little green button\xa0\n

to click that. And you can see that down here, a\xa0\n

to the screen, hello, world. Now that we've\xa0\n

very simple. And that is how we go about setting\xa0\n

for right now, again, remember is going to happen\xa0\n

I'm gonna explain that later. public static\xa0\n

you want to print another line, you want to\xa0\n

I'll show you how that works. So I'm gonna say\xa0\n

hello world, too. And if I save this, and run\xa0\n

So you can see where we are right where we left\xa0\n

world to to the screen. And in this video, I'm\xa0\n

the absolute fundamentals, we have to understand\xa0\n

So let's talk about what a variable is. Now a\xa0\n

that holds a value. Now in our case, that doesn't\xa0\n

could be a Boolean, and integer, like we're going\xa0\n

are what are known as data types, or objects. So\xa0\n

a variable, we need to first figure out what\xa0\n

I'm going to start with an integer. And then\xa0\n

types and talk about the differences. So to start,\xa0\n

that we're about to type out is going to be an\xa0\n

name. Now the variable name should contain\xa0\n

I believe you can use numbers as long as it's at\xa0\n

do that when we create a variable name, you have\xa0\n

don't use any special characters as well. So I'll\xa0\n

and invalid variable names. So a valid variable\xa0\n

because we don't have any spaces. We don't have\xa0\n

and Okay, now, an invalid variable name would\xa0\n

thing as our variable name is invalid, because\xa0\n

what do you call it percent sign like this, or\xa0\n

valid variable name. So don't use any special\xa0\n

could start with an underscore if you want to. But\xa0\n

Typically, when you create a variable, if you want\xa0\n

it is you type like Hello, and then you would do\xa0\n

an underscore representing a space. And then next\xa0\n

Not super important right now. So I'm going\xa0\n

and that's going to be equal to by just putting\xa0\n

case, we're gonna say five. And then remember,\xa0\n

just saying my integer Hello, world is equal to\xa0\n

there we go. And we see we get int, our variable\xa0\n

issues. So if I let's just see what it says this\xa0\n

officially created a variable, the variable name\xa0\n

prove this to you, I am simply going to print\xa0\n

so I'm gonna say system dot out to comment is\xa0\n

do is we're gonna say, okay, so hello, underscore\xa0\n

holds five. So when we print this, we should be\xa0\n

right? Is it says, Okay, hello, world. Let's\xa0\n

hello, world is equal to five. So we print that.\xa0\n

down here in the bottom of the screen. Now I\xa0\n

is just going to go this is a really important\xa0\n

in programming tutorials. It's kind of like order\xa0\n

put my variable underneath my System dot out dot\xa0\n

world. And then I'm going to set hello world equal\xa0\n

the issue might be here. If not, I'll talk about\xa0\n

trying to print the value of hello world before\xa0\n

the way things work is unless you otherwise\xa0\n

bottom and left to right, just the way you'd read\xa0\n

dot out dot print ln a Hello World, and then we\xa0\n

hello world is. So if we tried to do this, you\xa0\n

you know what, there's an error. Let's proceed\xa0\n

we get a bunch of red text. And it says, What\xa0\n

to a variable, because we haven't yet declared\xa0\n

we're referencing or using variables that we\xa0\n

like the line that we're using them in. Okay. So\xa0\n

we print that to the screen. Now, let's create a\xa0\n

types are. So in case I didn't really specify\xa0\n

stands for any number that does not have a decimal\xa0\n

like 5.0, this actually becomes a new data type.\xa0\n

stands for floating decimal point, which means\xa0\n

so I'm gonna say float. Let's see, num. Two\xa0\n

and in this case, I'm going to say 5.0. What's\xa0\n

one second where I said double. So sorry, I made\xa0\n

as the name Okay, not float. Don't worry about\xa0\n

anyways, we have double num two equals 5.0. Now\xa0\n

anything that has a floating decimal point. So\xa0\n

this in terms of mathematics, because it has\xa0\n

is referenced as a double. Okay? Now, there's some\xa0\n

about. So we have int, we have double, we also\xa0\n

is true or false. And these are gonna be really\xa0\n

about. So Boolean, I'm just gonna say B as my\xa0\n

this case, I'm going to say true. And again, make\xa0\n

two values that a that your boolean data type\xa0\n

are important is because based on the value of a\xa0\n

in our program. Like if B was equal to true, we're\xa0\n

something. So that's really important. So another\xa0\n

is any character. Okay, so this is a little bit\xa0\n

last video, but I'm going to talk about string\xa0\n

and whenever we create a character, there's two\xa0\n

which you probably don't know what that is. Or\xa0\n

just simply hitting the single quotation marks, we\xa0\n

and that is a character because that's what char\xa0\n

your keyboard, in quotation marks, now character\xa0\n

so that's still a valid character. Because it's\xa0\n

like nine if you're, if I were to type that\xa0\n

goes in quotation marks is a char. Now we have\xa0\n

one character, if I tried to, like 03, you can see\xa0\n

us, and it's saying no, that's not allowed,\xa0\n

now I just want to show you I want to go over\xa0\n

between this nine and this nine, up here we've\xa0\n

hello world, and it's set equal to nine. Okay,\xa0\n

since it's in quotation marks, this is not the\xa0\n

really do matter in this sense, okay. So I'm just\xa0\n

now. Okay. Choice equals h. So that is extremely\xa0\n

It's a different kind of data type, which we'll\xa0\n

we do string I believe with a capital We'll see.\xa0\n

in this case, I'm just gonna say str is equal to,\xa0\n

quotation marks, okay? And I'm just gonna say\xa0\n

and strings are double quotation marks, okay? And\xa0\n

have like 673 underscore star, that's a completely\xa0\n

they're with inside of these quotation marks.\xa0\n

a nine in a string, this is different than a nine\xa0\n

there are a few other ones, but I'm not going\xa0\n

a bit more complex than than we can handle right\xa0\n

this string is highlighted as a different color\xa0\n

Booleans, orange chars orange, why is string\xa0\n

it's a different type of data type. These four\xa0\n

as primitive. And, wow, I really just did that\xa0\n

okay. And what that stands for, is not changeable.\xa0\n

data types and not primitive data types later\xa0\n

about here are known as primitive in Java. And\xa0\n

let's just see now, printing out like some\xa0\n

we print them to the screen, right. So if I\xa0\n

you should guess what we're gonna get, we get H,\xa0\n

and so on. Now, last thing I want to show you\xa0\n

variables equal to other variables, and we can add\xa0\n

gonna be doing a lot in the next video, but I want\xa0\n

I want to create a new integer, Okay, I'm gonna\xa0\n

let's just call it Tim, why not. Now I want\xa0\n

but I don't want to type nine out, what I'm\xa0\n

underscore, underscore world like this. Now what\xa0\n

from hello world, and we've assigned it to Tim.\xa0\n

we get the value nine. Now if I want to print\xa0\n

still getting the value of nine. So now Tim points\xa0\n

Tim is equal to nine and hello world is equal to\xa0\n

together, we can subtract variables, we can do all\xa0\n

of variables, right. So we just have to make sure\xa0\n

do something like this. String temp equals hello\xa0\n

from int to string, because the datatype string\xa0\n

do that until we learn about something called\xa0\n

Now in this video, I'm going to be adding on to\xa0\n

video. And I am going to be talking about basic\xa0\n

exponential, all of that fun stuff. So without\xa0\n

going to do is just talk about another way that\xa0\n

you saw me do something like this index equals\xa0\n

know this. But there's another way that we can\xa0\n

we can actually omit this equal six. So if we\xa0\n

now is we've declared that x is a variable,\xa0\n

we've declared it but we have not initialized it.\xa0\n

System dot out dot print ln, and we're simply\xa0\n

probably helped I spelt print correctly. Okay.\xa0\n

okay, run this. And you can see, we are already\xa0\n

but and it says the local variable x may not have\xa0\n

the variable x, when we set up like this, we\xa0\n

underneath this declaration, we can just say x is\xa0\n

be as long as it's an integer value. So in this\xa0\n

we run the program, everything looks fine, and\xa0\n

every data type. So if I do like char, and char\xa0\n

single quotation marks, f like that. Okay, then we\xa0\n

what I want to talk about now is operations.\xa0\n

I'm going to say integer x equals five. Don't\xa0\n

and I'll say int Zed is equal to 50. Okay, I'll\xa0\n

going to start talking. So what I want to do now\xa0\n

seven, and five. But I don't want to write like 56\xa0\n

the value of these variables, this works fine. But\xa0\n

that means I have to go down here and I have to\xa0\n

if I want to change x and y? Well, that means I\xa0\n

cool thing that we can do. And we can just use the\xa0\n

x plus y, plus Zed like this, okay. And now our\xa0\n

three variables. And to prove it to you, I will\xa0\n

get 68 as our sum. Now, Furthermore, if we wanted\xa0\n

them, all we have to do is simply replaces with a\xa0\n

multiply things, this is another operator, we can\xa0\n

multiplication, and we'll multiply all these out\xa0\n

divide, we can use the forward slash. Now I'm not\xa0\n

of a different topic. There's a weird thing with\xa0\n

do that. So those are four basic operators. Now,\xa0\n

of order of operations, right? So we're gonna\xa0\n

or brackets, exponents, division, multiplication,\xa0\n

guys know order of operations. So that means\xa0\n

What's first going to operate is x multiplied\xa0\n

whatever this value is. Now again, if I switch\xa0\n

going to happen first is y multiplied by Zed, and\xa0\n

example, if we have the operators that have the\xa0\n

order of operation level, I don't know what to\xa0\n

to right, so it's going to do x multiplied by y\xa0\n

a lot people to understand this. If we do a\xa0\n

y, and then we're gonna divide by Zed afterwards.\xa0\n

whenever we're doing operations like this, we\xa0\n

example, say x multiplied by y, and then divided\xa0\n

brackets in here. So now it's showing 100% that\xa0\n

same thing, if I did this, now, whatever's\xa0\n

then I can divide by said, and obviously we can\xa0\n

multiplied by y, times y, okay? Like, get out\xa0\n

that's totally acceptable. And that totally works.\xa0\n

more specifically, and then go into a few more\xa0\n

different. In Java, is it just in general, okay.\xa0\n

divide Zed by y, okay? And I some just do you,\xa0\n

this out to the screen. 56 divided by seven, gives\xa0\n

for the variable u, which is holding the value of\xa0\n

So it actually isn't able to give us a floating\xa0\n

is a floating point number, or is it a? Let's\xa0\n

divided by this guy. Yeah, so we can't give us a\xa0\n

datatype. So it assumes that we want an integer\xa0\n

value and terminate all the decimals guy. So say\xa0\n

us eight, right? removes the remainder. Now if\xa0\n

to do most the time, I could try to do something\xa0\n

by y. And you mean Okay, that makes sense double\xa0\n

But watch what happens around this, we just get a\xa0\n

is not 8.0. It has some decimal component to it\xa0\n

we getting that? Well, that is because the two\xa0\n

which means when we get a value back from this,\xa0\n

do is convert it into double because we have this\xa0\n

so how can we ensure that we get a floating point?\xa0\n

first change the bottom to be a double. And we\xa0\n

do like this, it's like double. And I could change\xa0\n

of these double, and we try this, now I can\xa0\n

shows up and gives us like, whatever that is. Now,\xa0\n

and this is double i'd let's try this. Now, you\xa0\n

because if one of the values that we're dividing\xa0\n

the whole thing a double. So one of them is a\xa0\n

is the way it works for all the operations. So if\xa0\n

x times y, or let's say x times Zed, since Zed is\xa0\n

value. So if we run this, you can see that we get\xa0\n

a double, then that means everything is going to\xa0\n

exponent, whether we can explain it is we have\xa0\n

dot how. And then in here, you put the, what do\xa0\n

not a star star like in most languages, okay. I'm\xa0\n

And here, I'm simply going to raise x to the power\xa0\n

is it saying? convert doc. So let's do this. int,\xa0\n

interesting why it's telling you that let's just\xa0\n

get X, X, exponents, apparently they have to be\xa0\n

all right. So now if I want to print out D, what's\xa0\n

okay? So math dot pow, this is your base. And\xa0\n

five to the seven apparently is equal to that.\xa0\n

I guess. Obviously, you can have as many operators\xa0\n

things work in terms of doubles. And instead\xa0\n

operators that are operators variables that you're\xa0\n

then that means you're going to get a double\xa0\n

that means you're going to get an integer value\xa0\n

y back to double. And let's change you to be int.\xa0\n

that's x times x times y. Okay, so now you can see\xa0\n

double to Ent. And that is because we're trying\xa0\n

but y is a double value. So when we get a value\xa0\n

convert that into an integer just by doing this.\xa0\n

going to show you in a second, okay. So we would\xa0\n

it's nice in this ID, it tells you when you made\xa0\n

might not really see that in your program. Okay,\xa0\n

typecasting. We're going to talk about this\xa0\n

you like fairly quickly how this works. I'm\xa0\n

to turn these back into integers. Okay, so if I\xa0\n

and I want to make sure that I'm getting that\xa0\n

so a double, rather than converting these like the\xa0\n

can do called typecasting and to typecast, we are\xa0\n

the type of the variable, the way to do this is\xa0\n

to convert your variable into, and then directly\xa0\n

So in this case, it's double. And then we have y.\xa0\n

of D, you can see that we get the decimal value\xa0\n

right, then we do not get that or we do just go\xa0\n

So in this video, I'm just gonna be teaching you\xa0\n

last video. And we're gonna be talking about\xa0\n

called a scanner. Now this scanner is going to\xa0\n

all that fun stuff from the user and then do\xa0\n

basis of progress. All right, based on what a user\xa0\n

first thing that we're going to do is just teach\xa0\n

still going to take the very long excuse, I'm just\xa0\n

is what the name of the operator is modulus,\xa0\n

this case, I'm gonna pick five. Okay, so what this\xa0\n

Okay? Some people like to call a remainder\xa0\n

us the remainder of this division. So this\xa0\n

it 36 divided by five should give us 11? Okay, 11\xa0\n

equal to. So if we print x, we should get a value\xa0\n

the remainder operator is gives you the remainder\xa0\n

it too much more, I'm sure you guys want to get\xa0\n

now. Okay, so let's get rid of this line. And now\xa0\n

scanner is what we're going to do so well, first\xa0\n

program, you'll notice I have a new line here that\xa0\n

guys to type this out for me, Java dot util dot\xa0\n

this is what we're going to be using to get input.\xa0\n

to import them at the top of our program so that\xa0\n

And we'll get into this later when we talk about\xa0\n

so once we've done that, we need to set up a\xa0\n

the name of the scanner, I'm just gonna say SC is\xa0\n

we're gonna type System dot gains brackets. This\xa0\n

saying scanner is a dump type just like string\xa0\n

it's a different type of data type, but it is in\xa0\n

like one, or like putting quotation marks and\xa0\n

a new scanner. And what the scanner is going to be\xa0\n

And there's different types of scanners, which\xa0\n

we've set up our scanner, we need to actually use\xa0\n

going to type now is I'm going to say string scan\xa0\n

use next Yep. So what this does is we're creating\xa0\n

string type called scan. And it is going to get\xa0\n

Okay, so SC dot next is what allows us to get a\xa0\n

out scans after we get it because I want to show\xa0\n

and illustrate and we'll talk about it. So now\xa0\n

I'm able to type this because when type will\xa0\n

it prints Hello, underneath it. So hello, which\xa0\n

the scanner object using SC dot next, it got\xa0\n

were able to print scan out to the screen. Okay.\xa0\n

strings. Now watch this. If I type one, one works\xa0\n

going to do this with the MTA. So I'm gonna say\xa0\n

happening? What's wrong? Well, the issue right\xa0\n

which is what this returns to us into an integer.\xa0\n

se would proceed, we just run into an error,\xa0\n

what this method gives us is a string. Now, if we\xa0\n

for them typing, we have to use a another method,\xa0\n

see we're getting no more red lines, everything\xa0\n

we run this, then we type like 54. That works fine\xa0\n

I try to type in something like Hello, so there's\xa0\n

there's anything wrong. If I type Hello, we get an\xa0\n

type in a integer. And what happens in here like\xa0\n

is it tries to convert what I'm typing in,\xa0\n

integer. So when it tried to do this, it tried to\xa0\n

not you, not you or me knows how to convert\xa0\n

So now that that's not allowed, you can't do that.\xa0\n

get Booleans and other types, and I'll show you\xa0\n

So if we want to get a boolean value, we could\xa0\n

look at this Boolean? That's literally the name to\xa0\n

this. Now, note a Boolean has to be true. spelled\xa0\n

sure. So true, that works fine. But if I try to\xa0\n

that's gonna crash, it's going to give us an\xa0\n

once you get a double could do double equals\xa0\n

there you go. And now it's going to expect a\xa0\n

but I'm going to undo 6.3. And it prints out\xa0\n

just give us 6.0. So that works fine. Okay, to\xa0\n

issue of what happens like we get that crash,\xa0\n

how can we fix that if we're per se, when it's\xa0\n

what we should do is always get a string. So we\xa0\n

this into a string. And that's because a string\xa0\n

fine to be a string, because remember, a string\xa0\n

if I type true, although Yeah, we know it's a\xa0\n

really a string. Okay? If I type one, that's a\xa0\n

can be converted into a string, pretty much. So\xa0\n

a string, we can then convert it into an integer.\xa0\n

we're going to do now is we're going to attempt\xa0\n

in our case, I want to convert it into an integer.\xa0\n

to set up a variable. So I'm gonna say index\xa0\n

to put something with this scan, I can't just say\xa0\n

it's not just gonna be able to convert that for\xa0\n

need to do here is actually do dots, and are\xa0\n

okay. And then inside of the brackets for parse\xa0\n

is going to allow us to do is well convert into an\xa0\n

you don't know what it does, you can actually\xa0\n

it's going to say parses the string argument\xa0\n

the string must be old decimal digits, except the\xa0\n

so we can tell you it tells you exactly what this\xa0\n

class. So yeah, it'll convert that for us, so\xa0\n

would work fine. Now, the thing is that when this\xa0\n

is, we still run into the same issue because\xa0\n

we still get a crash, because how do we can\xa0\n

really first check if the value is an integer.\xa0\n

I believe, the next one or the one after that, how\xa0\n

else statements and error catching later on. So\xa0\n

now. If you know, you're going to be getting an\xa0\n

you could just do next int and turn this to an\xa0\n

So in this video, we're going to be\xa0\n

like greater than less than or equal to not really\xa0\n

which you'll see if you don't really understand\xa0\n

and how we can use those Boolean variables to do\xa0\n

about in the first few videos. And if you guys\xa0\n

well, this video will show you. So without further\xa0\n

off by typing a few numbers here because it's\xa0\n

and then we'll do some other stuff. So I'm going\xa0\n

X is six, y is seven ends, that is 10. Now I'm\xa0\n

else, call it compare, and we'll just set that\xa0\n

want to compare x and y and Zed using some\xa0\n

I'm going to write them out here. We have a belief\xa0\n

we'll type them out and we can see, so the first\xa0\n

we have equal to, oops, we have greater than or\xa0\n

Now I know I just went through those fast but\xa0\n

going to state whether something is greater than\xa0\n

or whatever way you have it right? This is, is\xa0\n

than the single equal sign, double equal sign is\xa0\n

the same. And the single equal sign like this one\xa0\n

you remember that because a lot of people when\xa0\n

equal sign, and they just use one and they end up\xa0\n

or equal to pretty straightforward, less than\xa0\n

exclamation point and an equal sign. Now I'm going\xa0\n

I saw Actually, I'll leave that there. And because\xa0\n

teach you this. If you do two slashes in Java,\xa0\n

something that the computer is going to ignore.\xa0\n

can look at it and be like, Okay, this is what\xa0\n

doesn't care, so whenever it sees a line that\xa0\n

a comment. It just ignores that line and moves\xa0\n

just Gray's out in here to show us that that's a\xa0\n

and y. And I want to set see if x is less than\xa0\n

statement right here that we're typing here is\xa0\n

So we can look at this, we say, well, six is not\xa0\n

us a value of true. So if we print compared to the\xa0\n

Now, if I flip this around, and I say greater\xa0\n

Well, we get false, it's pretty straightforward to\xa0\n

we can do two equal signs. And in this case, we\xa0\n

some people get confused by. But if I do not\xa0\n

the two values on the left side and the right side\xa0\n

they're not the same, I get true. If they are the\xa0\n

the same. So we should be getting true. Okay. And\xa0\n

but they're pretty straightforward in terms of\xa0\n

these work fine. So greater than or equal to less\xa0\n

to compare strings, so I'm just going to change x\xa0\n

oops, string, x, will say hello, and string\xa0\n

now I'm getting this blurred out, or this red\xa0\n

greater than or equal to undefined for strings. So\xa0\n

at least for right now that we're going to talk\xa0\n

okay? And not equal to is simply going to say,\xa0\n

they are the same, so in this case, I say not the\xa0\n

if they are the same, I get false. Now, I want you\xa0\n

and I add a capital O at the end of Hello like\xa0\n

with all lower cases are not? Well, I'll show\xa0\n

program, right, let's assume with variable names,\xa0\n

lowercase variable y. Okay, so that's how we\xa0\n

can we use greater than net, we can't use\xa0\n

Okay. So what I'm going to do now is I want to\xa0\n

to show you the end operator, the OR operator,\xa0\n

add multiple conditions together to get one\xa0\n

I'm going to change these back to two numbers\xa0\n

equals what I have six into y equals, let's just\xa0\n

compare multiple things at once. So I first want\xa0\n

to compare if Zed is greater than x, say I want to\xa0\n

you'd want to do that. The way that we can do that\xa0\n

is using this an operator AND AND operator is\xa0\n

okay? And then we have to add another condition\xa0\n

Zed is arch, say Zed is less than y, okay? You can\xa0\n

And what this does is it's going to compare the\xa0\n

comparison on the right side, and then we're going\xa0\n

x is greater than y. So six, is that greater than\xa0\n

it out as if this is what's happening in the\xa0\n

it is. So we get true like this, okay? Now, we\xa0\n

this and operator in between them. What this and\xa0\n

the conditions on the left side and the right side\xa0\n

us. If they're both pretty one of them is false,\xa0\n

value. So in this case, since this one is false,\xa0\n

them have to be true for this to evaluate to true.\xa0\n

this to the screen, you can see we get a false\xa0\n

are true, then the whole thing is true. Okay. Now\xa0\n

And the OR operator is to straight up lines like\xa0\n

the key for that, but anyways, so this is gonna do\xa0\n

around, if one of the two conditions are true,\xa0\n

if both of them are false, it's false, right?\xa0\n

right is we'll do this condition, we'll see what\xa0\n

is equal to. And if one of them are true, we get a\xa0\n

we get a true value. Now, we have a knot operator.\xa0\n

anything. And this is what I like to think about\xa0\n

reverse it. So what this does is it's going to say\xa0\n

Or if this condition is false or not true, then\xa0\n

is true, then it's false. Because it's checking if\xa0\n

of just have to play with it to make sense of it.\xa0\n

we have this exclamation point, which is our NOT\xa0\n

here we get false. Now if in here I were to put a\xa0\n

by typing in the value, I say not and then false\xa0\n

So it's simply just reverses like anything that\xa0\n

we can actually combined all of these operators\xa0\n

ands and ORS and we can have an infinitely\xa0\n

evaluate to true. Now this is actually some kind\xa0\n

university, I'm gonna have to do it next semester,\xa0\n

and you have to figure out if you're going to\xa0\n

you like a pretty basic example. So I'll say if x\xa0\n

plus two is less than five. Or what do you call\xa0\n

so I just typed a bunch of conditions, right?\xa0\n

are going to evaluate first? Well, that is a good\xa0\n

this. Because just looking at this, like even\xa0\n

it in. I'm like, wow, okay, how do I determine\xa0\n

typically, you put things in brackets, so I would\xa0\n

so I have this first conditional, right? You put\xa0\n

this case, we'll get I'm not going to bother doing\xa0\n

okay? Or so we have true, or whatever this\xa0\n

going to do now is it's going to look at said plus\xa0\n

then we get true or and then whatever this is,\xa0\n

brackets like this. Okay. So now the way that this\xa0\n

we get a value of like true or false. We do\xa0\n

true or false. And then we'd see if either of them\xa0\n

let's just print it to see what we get. If we get\xa0\n

be honest. And yeah, that's how we could do\xa0\n

too. So if I want to throw a knot like this,\xa0\n

going to see massive chain conditionals like this,\xa0\n

it's difficult to determine what they are by just\xa0\n

and else statements in the next video how we can\xa0\n

I just wanted to show you that you can combine\xa0\n

have to use variables, you can see that here I put\xa0\n

valid condition that works perfectly fine, can\xa0\n

add constants, like I could just say two is equal\xa0\n

compare with constants. And with strings, just\xa0\n

sorry, not less than not the not equal to or equal\xa0\n

you'll see as we continue going through the video,\xa0\n

In this video, we're going to be going over if,\xa0\n

just I want to fix a really small mistake I made\xa0\n

I am like a Python programmer typically. So I'm\xa0\n

first language. So I'm used to being able to use\xa0\n

that's what you can do in Python. But in the\xa0\n

on strings. Now, that's not incorrect to do that,\xa0\n

now. So if you want to compare if two strings are\xa0\n

have the same, what you should actually do is say\xa0\n

do dot equals Okay. And then inside of this equals\xa0\n

to compare it to, or you're going to put another\xa0\n

I want to say if like, my scanner object, which\xa0\n

to Hello, this is how I would do it with this dot\xa0\n

equal signs isn't wrong, but it's going to give\xa0\n

that in future videos, but it's too advanced to go\xa0\n

compare two strings, use dot equals My apologies\xa0\n

do now is we're going to do it using if and else\xa0\n

do this, otherwise, do this. And this is the\xa0\n

on like user input, or based on certain events\xa0\n

right? So they're really important to understand.\xa0\n

getting, I'm just setting up a new scanner object,\xa0\n

already talked about this. And what I want to do\xa0\n

on what they type in, I want to do something.\xa0\n

you simply type if you put brackets, and inside\xa0\n

And this is why I spend so much time talking about\xa0\n

if this condition evaluates to true, whatever's\xa0\n

whatever's inside of these curly braces is going\xa0\n

I say if s dot equals not two equal signs, and\xa0\n

user types in Tim, when we're when we prompt them\xa0\n

going to happen is inside of these curly braces,\xa0\n

an if statement, or an IF block. So this block\xa0\n

these brackets inside the brackets as a condition,\xa0\n

as you want, as long as you're going to get a\xa0\n

have these curly braces, so an open brace and a\xa0\n

that I typed in here is going to happen if this\xa0\n

test here. And I'm going to do system dot out.\xa0\n

you typed Tim, okay, what types you types? you\xa0\n

see what happens. So when I run this, if it loads\xa0\n

so we're back, I accidentally closed my console.\xa0\n

So I got that up and running now. Let me\xa0\n

I don't know why. That's why But anyways, let's\xa0\n

let's type hello and see what we get? Well, we get\xa0\n

it again. Let's try it. And this time I type Tim,\xa0\n

basic if statement is working. Now I want you to\xa0\n

we can see what happens when we have like just\xa0\n

I'm literally going to print print. Okay. So now\xa0\n

what is the program going to run? So if we type\xa0\n

we still going to get this print out here? Or are\xa0\n

and see, okay, so in this case, I typed Tim. So\xa0\n

it says print, okay? Now the reason that happens\xa0\n

right? So we're just going to execute simply\xa0\n

right? If I type, like Hi, it's still going to\xa0\n

It didn't go through this if block but this is\xa0\n

or whatever. So that executes. Okay, so that's\xa0\n

you else and elsket rest start with else. So else\xa0\n

and else if or and if so, like the start of\xa0\n

can't just have it like alone. It has to come\xa0\n

which we're going to go into in a second. Okay.\xa0\n

like to put the else like this Has the closing\xa0\n

to do it like this. Some people like to do it like\xa0\n

fine. Just make sure that your curly brace doesn't\xa0\n

because that's kind of hard to read. Okay. So\xa0\n

print statement, and I'm going to put it in my elf\xa0\n

if this happens, that's fine. We're going to go\xa0\n

we'll move down to the end of the block. So we'll\xa0\n

this doesn't happen, so other words, or else, then\xa0\n

Tim or print, we're never printing both because\xa0\n

so let's test this out. If I type Tim, we you type\xa0\n

random letters, and I hit Enter, you get print.\xa0\n

this condition is not true, right? Okay, so that's\xa0\n

about that anymore. The next one I'm going to\xa0\n

add multiple if conditions in one kind of block.\xa0\n

And now it's the exact same syntax as regular if\xa0\n

And obviously, since this is an else it has to\xa0\n

have as many of these else ifs as you want. Now,\xa0\n

s dot equals, and in this case, let's just say\xa0\n

system, dot out, dot print, ln, and we'll just say\xa0\n

Hello. Okay, so again, the way this is gonna work,\xa0\n

we're gonna get our scanner input, we get\xa0\n

if it is we're gonna print this, and then we're\xa0\n

we're not going to even bother checking if it's\xa0\n

then we know that we shouldn't bother looking at\xa0\n

what we're going to do is we're going to go\xa0\n

that's our next block, is it equal to Hello,\xa0\n

we're gonna move on with our lives, you're gonna\xa0\n

going to the else. Okay? Now, if it's not equal to\xa0\n

And we're just simply going to print print,\xa0\n

going to happen. If you print anything other than\xa0\n

so let's try this out. And let's type Hello.\xa0\n

if I print type anything else in here, like some\xa0\n

how that works. Now I can show you I can add as\xa0\n

simply paste it down here, gonna have another LCF.\xa0\n

I could type Hello. And we could keep going.\xa0\n

know that whenever you have a kind of a block\xa0\n

if statement. And it does actually doesn't have to\xa0\n

last thing so if you have any else ifs else will\xa0\n

and then try typing like that's, that's not\xa0\n

that's perfectly fine. So now I have if we type\xa0\n

And let's type none of them. Let's, let's type a\xa0\n

screen because we don't have that l statement.\xa0\n

right we went through wasn't equal to Tim. It\xa0\n

I want to show you this. This is a bad example.\xa0\n

Hello here. Which one are we going to print? So\xa0\n

things. We're not going to print more than one.\xa0\n

let's test it out. If I type Hello in here, we\xa0\n

is because this else if is above this one, and\xa0\n

at when we type something in just the way I kind\xa0\n

high here, we're like, Okay, well that happened.\xa0\n

move on. Okay, straightforward. Now again, I could\xa0\n

typing like do a bunch of stuff, just understand\xa0\n

need to know stuff. Like we could just do an IF\xa0\n

like an if statement or block starting it has to\xa0\n

you want. And the last thing has to be an else.\xa0\n

else there. So anyways, I think that's all I'm\xa0\n

they're pretty straightforward. Any condition can\xa0\n

like you could have a really long chain\xa0\n

you could have any condition like it doesn't\xa0\n

value, you could also literally just type\xa0\n

In this video, we're going to be kind of taking\xa0\n

that we've already learned summarizing that,\xa0\n

you guys really understand all of that. And we're\xa0\n

how you can kind of add things within other things\xa0\n

variables. And the way I'm going to do this\xa0\n

it's going to do is it's going to ask the user to\xa0\n

going to do certain things with that, we're going\xa0\n

like on a roller coaster, like if you're 13 or\xa0\n

going to do something like that. Okay, so I'm\xa0\n

because we want to get the user's age. But um,\xa0\n

going to print a line to the screen here. So\xa0\n

and so print ln. And in this case, I will just\xa0\n

it should, if I'm doing this correctly, make\xa0\n

line. Okay, you'll you'll see when we do that in\xa0\n

just going to kind of start typing, and we'll go\xa0\n

and we're actually just going to convert this\xa0\n

so using that parse into that I was talking about,\xa0\n

I always forget how to do this integer dot\xa0\n

so we're going to convert whatever they type\xa0\n

to assume that they type in an integer. So we'll\xa0\n

we will simply print System dot out dot print,\xa0\n

if they're not older than 13, that must mean\xa0\n

So in this case, we will simply print that they\xa0\n

you cannot write exclamation point. Okay, pretty\xa0\n

this work. So let's test it out. input your age\xa0\n

input your age 43. You can ride awesome. Okay,\xa0\n

what I'm going to do is I am going to add a elsif\xa0\n

that we're looking at. So I'm going to say now I\xa0\n

either an adult, a teenager, or just like younger\xa0\n

call those? Whatever, younger than teenagers.\xa0\n

I want to print you are an adult, okay? Now\xa0\n

we want to check if they are less than 18. So or\xa0\n

way, that's gonna make sense here in a second. So\xa0\n

we know it's less than 18. So all we actually\xa0\n

right? We're greater or older than or equal to 13?\xa0\n

reason we don't have to check if they are, what\xa0\n

is because we already know that they're gonna\xa0\n

within that range. So I already butchered that\xa0\n

dot print, ln. And in this case, we'll just say\xa0\n

this last case, well, we know they're not older\xa0\n

than or equal to 30. And that meaning they must\xa0\n

adult, okay, like that. So let's test our program\xa0\n

input an age of 14, we get you are a teenager.\xa0\n

age of 19. Get you're an adult. And if we input an\xa0\n

adult. Now, I want to show you what happens if\xa0\n

do like negative 98? You are not a teenager or an\xa0\n

that's not greater than or equal to 13. It's not\xa0\n

a teenager or an adult. Okay. Now, that is pretty\xa0\n

is how we can ask like another question or how we\xa0\n

here is I want to say, if they're 18, and only\xa0\n

What should the question be? I want to ask them\xa0\n

going to do now exactly what I've done up here,\xa0\n

So if this happens, we're going to do this and\xa0\n

gonna say SC, or we'll say, string is Windows to\xa0\n

guess Kazumi food Yeah, we'll say string. Food\xa0\n

And what I'm going to do is I'm going to print\xa0\n

just copy this in a second. And in this case, I'll\xa0\n

do is I want to check what their favorite food is.\xa0\n

I'll say mine too. Otherwise, we'll say that's\xa0\n

we'll say if, and we have our conditioning here,\xa0\n

we'll simply type pizza. Right? Then we will\xa0\n

mine. Wow, inside of the coats, hopefully. Say\xa0\n

we'll do is we'll simply type system, dot out dot\xa0\n

Okay? So this is showing you now it looks a bit\xa0\n

statements and else statements, we can do things\xa0\n

that this works. So if I type, I'm 19. It's gonna\xa0\n

let's try pizza, says mine too. Awesome. That's\xa0\n

like for, it just tells me I'm not a teenager,\xa0\n

happening inside of this if statement, or this\xa0\n

And that allows us to do some neat things. And\xa0\n

putting a statement inside of another statement,\xa0\n

So I just wanted to show that to you. Because\xa0\n

they don't understand that you're able to do that,\xa0\n

again, if I want to ask another question, I could\xa0\n

What is an array? Well, an array is a collection,\xa0\n

rather than having like a variable equal to one,\xa0\n

different values in there that you can index\xa0\n

talking about them here, if you're a little bit\xa0\n

you have to declare the type that you want your\xa0\n

at least right now have to be the same type. So in\xa0\n

And to declare that this is going to be an array,\xa0\n

in square brackets, the name of your array in this\xa0\n

and then in this case, you're going to say new\xa0\n

brackets, you have to define how many elements or\xa0\n

I'm just gonna say five. Okay, so you can\xa0\n

just because we're not using new AR. But yeah,\xa0\n

it to be, you type the type. So if I wanted to\xa0\n

would have to be the same string like that. Okay,\xa0\n

and then the type square brackets how\xa0\n

there's another way to declare this, I'll show\xa0\n

like you can't change this length. So you have to\xa0\n

you know how many elements you want to have.\xa0\n

zero, then there's no point in using it. You can't\xa0\n

okay? And what it's going to do is it's going\xa0\n

no, so they have no value, but they exist, like\xa0\n

right now. Okay? Well, you can kind of think of it\xa0\n

are old gonna hold something, but they're not yet\xa0\n

So we're gonna keep the string array for now.\xa0\n

and change values and print them out and see\xa0\n

index things in an array and array is going to be\xa0\n

so I'm just gonna type some stuff out and just\xa0\n

have Hello. I need double quotes. Hi, Tim. Maybe I\xa0\n

Now these are the five values in my string array.\xa0\n

showing you an example. Now the way that we start\xa0\n

this, every element in our array is going to have\xa0\n

number that represents its position. So in this\xa0\n

is position two, and this would be position five.\xa0\n

position one, it would give me Hello. But the\xa0\n

we actually start counting at zero, meaning\xa0\n

actually going to be position zero. And that means\xa0\n

this case, five, the last position in my array is\xa0\n

four, so Joe would be position four. And these\xa0\n

index one is high, index two is Tim. And this\xa0\n

without having to know their value, we just know\xa0\n

That's how we count in computers. Okay, so how can\xa0\n

I'm going to create a variable and just say\xa0\n

get like value two in my array. So first of all,\xa0\n

we'll do that in a second. But how I would do that\xa0\n

brackets and then in here, I put the position. So\xa0\n

the first or second position I will see anyways,\xa0\n

the second value in my array, because remember, we\xa0\n

be zero, and the last value would be four. Now\xa0\n

start adding things into my array. So the way that\xa0\n

we've declared an array and we set it has length\xa0\n

exists, or those buckets, there's not holding\xa0\n

say new AR zero is equal to, and in this case,\xa0\n

put our semicolon, there we go. We've just set\xa0\n

Okay, so now if I copy this a few times, I can\xa0\n

I did 012, and three, and here, I can just change\xa0\n

And we can add one more, but we don't have to. So\xa0\n

of it. And new AR four is equal to what we call it\xa0\n

Okay, jus like that. Alright, so it may say string\xa0\n

equal to Joe. So to print this out to the screen,\xa0\n

this case, I will say x, and let's see what we\xa0\n

these into the array. Now if I just comment this\xa0\n

we do a new AR for let's see what we get, we get\xa0\n

we initialize this array, we set it of a length of\xa0\n

we've got five containers, five buckets, they're\xa0\n

are yet. Alright. So if we haven't set a value\xa0\n

well, we don't know what it is. So we're just\xa0\n

right now. Okay. So yeah, so those are, that's\xa0\n

I'm going to create another array and show you a\xa0\n

gonna like statically type in numbers, okay,\xa0\n

edge to save me from doing all these quotation\xa0\n

to new it square brackets. Or actually, we don't\xa0\n

we're just gonna put two curly braces. And in\xa0\n

this case, this is now my number array. So I put\xa0\n

354, six and six. Now again, just to recap, two\xa0\n

Because that's where we start counting. And now,\xa0\n

error, I'm going to say nums four, which should\xa0\n

this has to be an int, my bad. index equals lumps\xa0\n

value six. So that's another way to create an\xa0\n

all of the numbers like that, okay. And obviously,\xa0\n

we could do string we do float, we do double,\xa0\n

equal to and then in here, like 2.0 3.0 There you\xa0\n

well, you need But that works. Okay, we now have a\xa0\n

one, we have 3.0. And yeah, so arrays can get\xa0\n

thing to be using for a lot of example cases. But\xa0\n

videos, I'm going to be talking about collections,\xa0\n

things rather than like indexing elements like\xa0\n

on those. But for now, I would just want to\xa0\n

So in this video, I'm going to be talking about\xa0\n

of every programming language. And\xa0\n

I can almost guarantee you that any program you\xa0\n

a for loop is allows us to kind of automate a\xa0\n

typically when you use a for loop, you're using\xa0\n

to do something or like a condition is going\xa0\n

opposed to what we're going to talk about in\xa0\n

you're not really sure how long it's going to go\xa0\n

but we'll talk about that when we get to it.\xa0\n

the for loop can really like solve for us,\xa0\n

simple example. And you guys will see in a second\xa0\n

that I want to add one, and then I want to add\xa0\n

and four, and five and six, and like an infinite\xa0\n

Well, we could do like x plus equals one, we could\xa0\n

things to x. And we could just keep copying and\xa0\n

that's terribly inefficient in terms of a typing\xa0\n

what if every time we want the program, we want\xa0\n

like a pattern like this to x? Well, then we would\xa0\n

right, so this is where for loop can kind of come\xa0\n

going to type it out, and then we will talk about\xa0\n

here and in here, we're gonna put three things\xa0\n

going to first start off by declaring a variable.\xa0\n

zero, okay? Now this can be called whatever you\xa0\n

x, but you know, let's just use AI. And then what\xa0\n

a semicolon, and then the next thing you're gonna\xa0\n

gonna do this and then talk about because it's\xa0\n

all work together, less than or equal to 10. And\xa0\n

actually, is I first started by declaring a\xa0\n

we're going to do this while i is less than or\xa0\n

So pretty much the way this works, is every time\xa0\n

here, is gonna have one added to it. So this is\xa0\n

the end of your for loop. So this is what you're\xa0\n

here, every time you run the loop. Now this here\xa0\n

many times a loop is gonna run. So in our case,\xa0\n

than or equal to the value 10, meaning we're going\xa0\n

we're going to run this loop, then we're going to\xa0\n

we doing? We're adding one to AI, then we're gonna\xa0\n

we're gonna say, well, is one less than equal\xa0\n

through, and we're gonna continue looping through\xa0\n

to i, it's equal to 1111. Well, that's greater\xa0\n

guys will see when I start printing stuff to the\xa0\n

was a decent explanation of the way to do this.\xa0\n

out here and I'm going to tell you right, now\xa0\n

at zero. So the first loop here, where I come\xa0\n

next loop, we come up, we add one, two, I check\xa0\n

We're at one, and we're going to print from zero\xa0\n

the way up to 10. Okay, that's how the for loop\xa0\n

little curly braces 10 times, or 11 times in\xa0\n

we can change this increment, we can change this\xa0\n

do in this for loop. So here we say for int i\xa0\n

and I can start at the value five and now we're\xa0\n

looping 123456 times, right? We're printing six\xa0\n

that If I tried to do something like i equals\xa0\n

the screen. And that's because 11, well, that's\xa0\n

even run one time, right. So let's go back, and\xa0\n

can do in terms of incrementing. So to increment\xa0\n

we want. So in this case, if I do five, we started\xa0\n

add five again. So we get 05, and 10. And you can\xa0\n

same thing here with the condition. These can\xa0\n

tell you that. But if I do something like int\xa0\n

right, and we can add that integer to it, we\xa0\n

equal to this could be greater than this can be\xa0\n

quickly go over one thing that a lot of people\xa0\n

when we're going to stop and when we're going to\xa0\n

this means we're going to start at this value. And\xa0\n

to stop but include 10, meaning that I will hit\xa0\n

if I remove this equal sign, this is only going\xa0\n

that if I is 10, well, 10 is not less than 10. So\xa0\n

you can see we only get up to the value nine. Now\xa0\n

we typically want to do with loops is we want to\xa0\n

typically that data is in the form of an array.\xa0\n

I'm going to create an array, so an integer\xa0\n

just give it some values here. So like 157345,\xa0\n

what do I want to do? If or how am I going to do\xa0\n

at look at these values, and maybe check them\xa0\n

or something like that? Well, the way that I can\xa0\n

is I could count the length of the reg and say,\xa0\n

than six year. But a more useful way to do this\xa0\n

way that I can do that is just to do a arc dot\xa0\n

sorry. So we'll just do this in this way, say the\xa0\n

them in an array, we don't know how many elements\xa0\n

length so that we can change this loop and this\xa0\n

Because we're just simply getting the length of\xa0\n

you guys realized this would cause us an issue.\xa0\n

array, right? But it's going to allow us to get i\xa0\n

array. Now what happens if I try to do this arr\xa0\n

that that will actually crash our program. And\xa0\n

our last element in the array is actually going\xa0\n

all the way to the length minus one, which is\xa0\n

what I'm going to do now, is I'm just going to\xa0\n

I'm just gonna say if the value is equal to five,\xa0\n

I'm gonna say if arr index i is equal to the value\xa0\n

dot out dot print, ln, I just realized this comma\xa0\n

to print the value. So in this case, we could\xa0\n

or we could just type five because we know\xa0\n

do found a five exclamation point, okay, that's\xa0\n

reason this is gonna work is because we're looping\xa0\n

but not including the length of the array, make\xa0\n

gonna get a crash, okay? So that way, we're going\xa0\n

we're going to check its value. And then if we\xa0\n

if this works. found five and found a five. Now\xa0\n

I found this five, I could say found a five at\xa0\n

can put pi. And what this is going to do is it's\xa0\n

into a string for us and print it out with this\xa0\n

so they don't get smushed together. But it says\xa0\n

index five and we know this is true. Index\xa0\n

a really simple way that we can loop through\xa0\n

Well, I'm going to be showing you a different kind\xa0\n

this is going to allow us to loop through the\xa0\n

and do something with those elements, I'm also\xa0\n

out of the loop at certain points. So if the\xa0\n

get out of the loop the way that we can do that,\xa0\n

of where we use loops. So let's go ahead and get\xa0\n

here one's name names, and one is named AR, I just\xa0\n

for right now. Okay, so what I first want to do\xa0\n

and the way I did that was by having a variable\xa0\n

greater than the length of the list? And then once\xa0\n

right? Okay. So an easier way to do this, is to\xa0\n

the same exact syntax, except in these brackets,\xa0\n

I'm going to do if I want to loop through every\xa0\n

this, I can say for element colon arr. Now what\xa0\n

sorry, string element, or I can't say string\xa0\n

in our array. So what I'm doing now is I'm saying\xa0\n

what we're going to do is we're going to declare a\xa0\n

equal to the next element in our array. So in this\xa0\n

equal to one, and then elements going to be equal\xa0\n

and then three, and then four, and then five.\xa0\n

like print out the element, or look at certain\xa0\n

like a counter variable i and then index all of\xa0\n

know the length of the array, or we don't want\xa0\n

going to go from start to end. Okay. Now, I'm\xa0\n

example to really understand this. But the first\xa0\n

out all these elements to show you that is indeed\xa0\n

okay. And we'll just print this to the screen and\xa0\n

157345, right, starting at the beginning going\xa0\n

again, we're just grabbing the elements in order,\xa0\n

a lot of times when you want to do with this is\xa0\n

want the index as well. So you want the element\xa0\n

we used in the last video where we just have a\xa0\n

and the element because we can do like arr of\xa0\n

typically do this is with like an outside counter\xa0\n

you how this works. So what we're gonna start\xa0\n

int count equals zero. And then within this loop,\xa0\n

every time that we run the loop, we're adding\xa0\n

the index of the element. So if I print out the\xa0\n

space plus our count, you can see that this is\xa0\n

here says one is that index 05 index one, and it\xa0\n

us. And that's a really easy way to do that.\xa0\n

sense for this example case, but I just wanted\xa0\n

where you want both the element and the index,\xa0\n

this with this colon. Okay. So again, when you're\xa0\n

because it's going through for each element in\xa0\n

so the next thing that I want to do is I want\xa0\n

for loop. So right here, for example, we have a,\xa0\n

right, like all these elements are null,\xa0\n

that we would go about doing this, and this is\xa0\n

while I'm showing you this is we create a variable\xa0\n

well, i is less than and then names dot length,\xa0\n

simply add one to it. So this is the exact same\xa0\n

how we can actually add the elements because it's\xa0\n

here is I'm actually going to use the scanner to\xa0\n

user. So I'm just going to say scanner SC equals\xa0\n

and actually think I should probably not declare\xa0\n

just going to use the scanner, right? So we'll\xa0\n

this. And this way, every time we run the loop,\xa0\n

know what, let's also just print out here, system,\xa0\n

I should let us do print not ln, we'll say, input\xa0\n

Okay, so input, we're getting input. And now\xa0\n

user's input into our array. So how can I do this?\xa0\n

is equal to input, right? So we're just declaring\xa0\n

so whatever value by well, that value in the list\xa0\n

an array I'm going to use to Python is going to be\xa0\n

to print out the entire array, what we can do is\xa0\n

and then this time, it's going to be a for each\xa0\n

string, and, and names, okay, then we will simply\xa0\n

print every value of n. Okay, so let's two good\xa0\n

everything's working. So we run this input, I'm\xa0\n

that, Tim, Bob. Joe, Bill. And then there we go.\xa0\n

Bob, Joe. And Bill. Awesome. There we go. So that\xa0\n

so now what I want to show you guys is how we can\xa0\n

and we're going through, and we're doing\xa0\n

where are like, so the loop is gonna keep\xa0\n

or whatnot. Okay, then we want to break out of it.\xa0\n

it in the middle of looping? Well, there is this\xa0\n

does, is whenever this is encountered inside of a\xa0\n

case, what would happen is, since I have break\xa0\n

then we just break. And this would only happen one\xa0\n

stuff said, this loop would only happen once. Now,\xa0\n

how we can break out based on like a certain\xa0\n

word end. Or what do you call it? The word Tim,\xa0\n

if we encounter like the word Tim, while\xa0\n

then we just want to break out like we don't want\xa0\n

break out. So the way that I can do this right now\xa0\n

but we'll break after Tim Okay, so what I'm gonna\xa0\n

and equals equals or not equals equals dot equals,\xa0\n

in here, then what we're going to do is we're\xa0\n

we encounter Tim, we're simply breaking into the\xa0\n

the names. So if I run this string, this console\xa0\n

name. And then we say, Tim, and I'll just show you\xa0\n

we get Hello, name and Tim. And these other two\xa0\n

we hit m, and n is equal to 10, we simply break,\xa0\n

a really easy way to just break out of the loop.\xa0\n

we do in what do you call it the next video.\xa0\n

to be using a lot like you only use this if you\xa0\n

conditions work the way they should, and have the\xa0\n

you know what I mean? So just try not to use this\xa0\n

with using it, people just are frowned upon it in\xa0\n

We're gonna be talking about while loops. Now,\xa0\n

anything you do with the for loop, you can\xa0\n

they do have different use cases in terms of\xa0\n

anything you do with the for loop, you can do with\xa0\n

you can do with the for loop, they're completely\xa0\n

them in programming, you'd still be able to do\xa0\n

nice to code, that's the right word for it, or\xa0\n

loop is going to work when you typically don't\xa0\n

something. So it's kind of like a question.\xa0\n

condition. But you're not really sure like, if a\xa0\n

it a set amount of times a while loop is it could\xa0\n

okay, something like that. So what we're gonna do\xa0\n

one up, and then we'll just talk about exactly\xa0\n

while loop to do is I want it to just continually\xa0\n

me like a certain word or like one or two words.\xa0\n

gonna say, let's see, maybe just get an answer\xa0\n

like this. Okay? And what I'm gonna do is I'm\xa0\n

the number 10. Okay, so all I can do this as you\xa0\n

these brackets is going to be your condition. Now,\xa0\n

the first few videos, because they go a lot with\xa0\n

this condition is true, then we're going to run\xa0\n

x does not equal 10. Okay. Yeah, exactly. That's\xa0\n

continue to do this. Otherwise, we will continue\xa0\n

to get the INT in here, because every time that we\xa0\n

in this case, we already have X, fine, we just do\xa0\n

10, I'm simply going to tell them like type in 10.\xa0\n

I will just say, type 10 dot, dot, dot. And\xa0\n

because I like to do this, we'll just do system\xa0\n

say type a number. Cesar knows what we're looking\xa0\n

print this here. And it should just be print, not\xa0\n

the way this is gonna work is we're just\xa0\n

this until eventually the user types in\xa0\n

and we will not do this anymore. So let's run this\xa0\n

data, type a number, type five doesn't work, type\xa0\n

and it no longer asked us for that number. Now,\xa0\n

this condition is true. Do everything that's\xa0\n

about while loops. Now again, like we can what\xa0\n

loops with while loops, because we can also count\xa0\n

I could do something like int count equals zero.\xa0\n

just say count plus plus. And then maybe at the\xa0\n

how many times they messed up. Okay, what am\xa0\n

And in this case, we'll just say you tried, tired,\xa0\n

make sure we add a little space here. Alright, so\xa0\n

you tried three times until like, eventually, you\xa0\n

to do stuff with while loops. Now, you guys\xa0\n

these lines are repeated up here. So I have this\xa0\n

this without repeating those lines? Because\xa0\n

wanted to ask a ton of different questions and\xa0\n

the same section of code appearing multiple times.\xa0\n

loop. So what I'm going to do is I'm just going\xa0\n

a do while loop. And it's pretty much what it says\xa0\n

And you'll see how it works in just a second.\xa0\n

and now everything in this brackets is what is\xa0\n

down here is true. So the condition here is going\xa0\n

going to do everything in here. So now you can see\xa0\n

I'm going to simply do is I'm going to take this,\xa0\n

So we're not going to redefine that every time.\xa0\n

this is going to allow us to do now is x does not\xa0\n

do this. int x and then x. Okay, perfect. There\xa0\n

But what this is going to allow us to do is we're\xa0\n

this is going to happen once because we're going\xa0\n

So we're automatically going to do this once which\xa0\n

down below. So we do that. And then we check the\xa0\n

And if it's not, then we will break. So we can\xa0\n

let's do five, let's do negative 00. Number, okay,\xa0\n

and everything is working fine. And that\xa0\n

if you wanted to set one up to look like a for\xa0\n

variable in this case, say like index equals zero,\xa0\n

and you say, x is less than or equal to 10. And\xa0\n

or plus equals two, or whatever value you want to\xa0\n

do in the for loop underneath your increment.\xa0\n

put it at the end. So at the end of the loop,\xa0\n

Now in this video, I'm going to be talking about\xa0\n

something known as the collection interface from\xa0\n

correct me if that's wrong, but I think that's\xa0\n

I'm just going to talk about really the basics\xa0\n

and lists. I know, I'm probably gonna get some\xa0\n

didn't talk about a lot of this, you didn't. But\xa0\n

Because it's very difficult to understand, if\xa0\n

which in our case, we don't. So I'm just going to\xa0\n

in a very basic standard implementation of them.\xa0\n

you're programming stuff, like a lot of Java\xa0\n

these, because they're really complicated.\xa0\n

things. So for example, with an array, what I\xa0\n

had to set the size of the array, like you had to\xa0\n

to do that with a set or with a list. And that's\xa0\n

we're gonna be adding things into per se a list or\xa0\n

be adding. So we can't define like an array of\xa0\n

actually just get started, we're gonna talk about\xa0\n

just gonna create a set, and I'm just gonna type\xa0\n

doing, I'm just going to call this set t equal\xa0\n

already probably looks confusing. And if you're\xa0\n

lines. Now, what we should do to get rid of these\xa0\n

click Import set by like clicking on whatever it\xa0\n

this Id just literally type import Java dot util\xa0\n

click on it and import it, just because this isn't\xa0\n

Alright, so we have a set. Now what is a set?\xa0\n

unordered elements that are unique, meaning that a\xa0\n

doesn't know where that element exists. So you can\xa0\n

and you kind of just throw things into it. And\xa0\n

knows that they exist there. Now you also have to\xa0\n

example, I've created this integer set. And this\xa0\n

set. In these little like greater than sign\xa0\n

if you're talking HTML type integer, and I have\xa0\n

hash set. Now you don't have to understand what a\xa0\n

implementation of a set. And then same thing, the\xa0\n

Now inside of these brackets, if you had another\xa0\n

called like W, I could put w in here. And assuming\xa0\n

of the elements from W and start with that and\xa0\n

Okay. So to add things to set, I'm just gonna\xa0\n

You simply type dot add, so I'm going to say T\xa0\n

And we'll just copy this and we'll add like a few\xa0\n

seven, and what five again, and add nine. Okay?\xa0\n

this set out to show you what it looks like. Now\xa0\n

elements. Okay, so let's print this out. And you\xa0\n

notice that this odd right here actually didn't do\xa0\n

a five in our set, when we try to add another five\xa0\n

and it just doesn't add it. Alright, now I'm gonna\xa0\n

negative negative zero, negative eight, alright\xa0\n

have any specific order. Now, see, when I printed\xa0\n

so you think that should be the order that we\xa0\n

or something like that. That doesn't happen with a\xa0\n

because again, we're just a bubble, we just know\xa0\n

or how many times they exist, we just care if they\xa0\n

and this is typically something you want\xa0\n

checking if something exists, that's why you use a\xa0\n

named contains, and then any element in here that\xa0\n

is contained in the set, and it's going to be able\xa0\n

explain to you why sets are so fast. But just know\xa0\n

set, you can do that very quickly, like very fast,\xa0\n

the set is, the set could be 2 million elements,\xa0\n

same amount of time to look if something exists\xa0\n

removing things from the set that happens almost\xa0\n

the array gets, the longer it's going to take us\xa0\n

just, we have to understand that. So what I'm\xa0\n

call Boolean, x is equal to this. And what I'm\xa0\n

x. Now let's see if that is contained. And in\xa0\n

if I do something like zero, then obviously we\xa0\n

we can type T dot remove, or set name dot remove,\xa0\n

remove. So in this case, we want to remove like\xa0\n

print my set, so in this case, t, which get five,\xa0\n

those are kind of like the standard operations,\xa0\n

okay, so there's one more, or there's a few more,\xa0\n

clear an entire set by just doing dot clear. So\xa0\n

To see if a set is empty, you can do.is empty, and\xa0\n

or not, to get the length of the set, you can do\xa0\n

so in this case, value, size, change this to an\xa0\n

three. So like, again, if we had nothing in there,\xa0\n

kind of like similar in the sense that you can\xa0\n

a hash set. A hash set is like the standard set.\xa0\n

to you. Now they also have a tree set. And we also\xa0\n

things, they're gonna pop up here, I'm not really\xa0\n

gonna kind of show you the way a tree set works.\xa0\n

you can only have the or a hash set, sorry that\xa0\n

actually ordered and they're ordered in a tree\xa0\n

this means just know that it's like it shows\xa0\n

just want to read this error. Tree set cannot be\xa0\n

well, let's just try this. That still worked.\xa0\n

me there. But Teresa is going to actually\xa0\n

you can see that we actually have an order\xa0\n

and seven. Now like arrays, like we can't just\xa0\n

like that doesn't work doing that, like we were\xa0\n

out, or when we look through the set, it maintains\xa0\n

really explain to you. Now linked hash sets are\xa0\n

to import this up there. It's linked hash set. And\xa0\n

certain operations. So I'm not I don't really\xa0\n

feel like I'm already confusing you guys, but\xa0\n

like operations and speed and time complexity.\xa0\n

and a tree hash set or tree set. Whatever I typed,\xa0\n

worry if this is a bit confusing, like, we're,\xa0\n

I just want to show you cuz I feel like you\xa0\n

your projects or whatnot if you're learning this\xa0\n

these are easier to understand, don't worry. But\xa0\n

what we're going to do is we're going to type\xa0\n

case, I'm just gonna give my integer type. And\xa0\n

just that's important that we need to use integer\xa0\n

I'm going to call this one Tega and equals\xa0\n

and we'll put brackets and there we go. Now we're\xa0\n

up there. And we now have an A list. And what\xa0\n

think of it as the exact same thing as an array,\xa0\n

so we can add things to it, we can remove things\xa0\n

or the end of the list, sorry, we can add another\xa0\n

like a dynamically sized array. These have pretty\xa0\n

things, you can do t dot add. And you can add like\xa0\n

that works fine. To remove things T dot remove.\xa0\n

we can actually index things with the list\xa0\n

it's not going to just care that it exists like\xa0\n

and then we can give an index, right? So even it's\xa0\n

I do dot index zero, then that would give me one,\xa0\n

put thing to put something or to set something on\xa0\n

and you type the index and the element. So I want\xa0\n

then that's where I would do it, index one is\xa0\n

you what it looks like. Okay, sorry, that's we\xa0\n

something. So to set something like this, sorry,\xa0\n

index. I forgot I didn't add that. So I'm just\xa0\n

is what this set actually does is you have to\xa0\n

And this is going to change that index for you.\xa0\n

And before I was trying to set one, when we didn't\xa0\n

there we go. So now that works. We've changed\xa0\n

right. So that's the way that that works. I've got\xa0\n

few of these set. Yeah, okay, so that's the basic\xa0\n

we can do t dot empty, or is empty. And this\xa0\n

list. And what this allows us to do is get from\xa0\n

argument, yeah, so we just need an int. So this is\xa0\n

So say I add like these a bunch of times. Okay,\xa0\n

do is I want to get from like index one to index\xa0\n

let's just take this and put this here instead. So\xa0\n

out and see what we get. So we get here now is\xa0\n

has what do you call it, like six elements in it\xa0\n

not including three. So if I type like 124, then\xa0\n

we get five one and two, because that's from from\xa0\n

four. That's what we're grabbing, we're getting\xa0\n

Now, this is ArrayList. We also have linked list.\xa0\n

really explain to you just understand that it is\xa0\n

So for any of you to understand the difference\xa0\n

And you guys, I recommend you to play with\xa0\n

we're coming up on about 15 minutes now almost.\xa0\n

with sets and lists. Now I know this video\xa0\n

lot of stuff that I wasn't able to explain to you\xa0\n

to do something and you don't know how long you\xa0\n

You don't know how long you want it to be. It's\xa0\n

you would just use an ArrayList the way that I\xa0\n

because then you can add things, you can get\xa0\n

to worry about like having a designated length.\xa0\n

how many times something exists or where it\xa0\n

reason a set is better is because it's simpler.\xa0\n

terms of like a computer efficiency standpoint,\xa0\n

be talking about hash maps, or like Java maps. The\xa0\n

different implementations of maps, similar as to\xa0\n

and like ArrayList, and all that stuff. So\xa0\n

you can think of them as dictionaries. And I'm\xa0\n

So a hashmap, a tree map, and what was the last\xa0\n

sorry, just forgot about that one. So pretty much\xa0\n

languages, they're typically called dictionaries,\xa0\n

to create a map, and I'm just gonna do this, and\xa0\n

just gonna create a map M is going to equal to new\xa0\n

syntax, now to we have to import this. So I'm just\xa0\n

it, we have to import map as well. So we'll import\xa0\n

up now for us. Okay, so now that we have that, I\xa0\n

like I said, is a key value pair, meaning that\xa0\n

sun, so you can index things. But instead of\xa0\n

keys. Now keys can be anything that you want. A\xa0\n

actually, I'm not sure if it could be an array,\xa0\n

it can be a char, it can be a float, what like\xa0\n

And that key links us to a value. So the easiest\xa0\n

and then to talk about what's really happening. So\xa0\n

what you do is you have to specify a key, and\xa0\n

map is, in this case, m dot put, and then you\xa0\n

for my key, I'm going to type Tim, and it is going\xa0\n

the value is five. So I put that in there. And\xa0\n

print this out to the screen. Because I think it\xa0\n

am I saying System dot out dot print ln Sorry,\xa0\n

see what we get. So in this case, you can see we\xa0\n

meaning that if we're to index Tim, we get the\xa0\n

actually get a value based on a key, the way\xa0\n

next to your map, are actually you can't do like\xa0\n

I'm still used to the Python syntax here, guys,\xa0\n

in here. So in this case, I'm going to put Tim as\xa0\n

what we're going to get out to the screen. In this\xa0\n

the key Tim leads us to the value five. Now to\xa0\n

right. So we do Tim we could do like Joe, and Joe\xa0\n

to another string. And that string could be like,\xa0\n

we want. Like we can have the the key one and or\xa0\n

and now if I just print em out, you'll see that we\xa0\n

get Joe equals x Tim equals 511 equals 999. Okay,\xa0\n

or don't type, whatever you want to call it,\xa0\n

to overriding to getting happens in constant time.\xa0\n

you don't really have to understand what that\xa0\n

know that this does happen in constant time. Now\xa0\n

and the what was the other map talked about linked\xa0\n

the differences between them. So with a hash map,\xa0\n

show you this one does not retain an order. So all\xa0\n

unique keys meaning that if I try to add another\xa0\n

998. Instead of adding another key that's equal to\xa0\n

key that is 11. So in this case, you can see that\xa0\n

have the same keys existing in the map. But you\xa0\n

Okay, so sorry, that kind of got me off track.\xa0\n

hashmap does not guarantee the order in which\xa0\n

Tim, and then I added Joe, and then I added 11.\xa0\n

any kind of sorted order, because how do we sort\xa0\n

It's not in the order that we added it in. So what\xa0\n

is why this hashmap is extremely fast, because\xa0\n

when they go in. So just know that if you're\xa0\n

you can iterate through maps, and I'm going to\xa0\n

the correct order. Okay. Now, the next map that\xa0\n

now this tree map is what we're gonna have to\xa0\n

or the tree set, or whatever one I showed you in\xa0\n

it's actually going to keep it in a sorted order.\xa0\n

kind of sort we're going to get. Okay, so we\xa0\n

a good area to run into. Whenever we're using a\xa0\n

to be the same, meaning that the keys have to be\xa0\n

I'm gonna just gonna see if I remove this, if this\xa0\n

we do get in a sorted order, we get Joe and then\xa0\n

that's where it's going to sort strings. So if I\xa0\n

it's even true on a key value, I'll literally\xa0\n

can't set equal we have a comma. What's our air\xa0\n

so we'll run this. There we go. So you see, we get\xa0\n

in the alphabet. So that's going to show up for\xa0\n

And that means that the data types for the keys\xa0\n

numbers, we can use strings using whatever data\xa0\n

same for that map. Now, the other type is a linked\xa0\n

list in that it keeps the same order that you add\xa0\n

you can see we get Tim Joe and then a and that's\xa0\n

in which we added elements. So it's gonna say,\xa0\n

be the first thing that we show. And then Joe,\xa0\n

second, and then a, this is gonna be the third\xa0\n

them in. And those are the only main differences\xa0\n

run out, that you have to kind of understand\xa0\n

anything, you're just gonna be using a hashmap,\xa0\n

or a tree hash map, or tree map, whatever it's\xa0\n

be doing right now. So what I'm going to do now,\xa0\n

can kind of clear the maps, how we can like remove\xa0\n

do. So what we can do to get all the key values\xa0\n

Actually, I'll just show this one first. Well\xa0\n

are going to be really useful to you. And dot\xa0\n

contains values not available for type map. Hmm,\xa0\n

so we just have to put something there. Okay.\xa0\n

we're just going to put like any value on so in\xa0\n

is actually going to check for us if this value\xa0\n

all these these second elements here. And they\xa0\n

it's going to tell us if b exists. Now we can do\xa0\n

useful. And I'll show you why in a second contains\xa0\n

contains the key five, right and that will give us\xa0\n

with sets and lists in the last video. Okay.\xa0\n

if I try to do something like m dot get, and I\xa0\n

does not exist, the value five exists, but the\xa0\n

when I run the program. m dot get five actually\xa0\n

Because I'm curious if this is gonna crash. Let's\xa0\n

so this isn't gonna actually crash for us. If we\xa0\n

not exist in the map, but it's going to return us\xa0\n

map. That's actually interesting. I didn't know\xa0\n

or from a dictionary, and it doesn't exist, you\xa0\n

know. Anyways, I guess another method I could\xa0\n

this is going to do is it actually just prints out\xa0\n

and I simply print it down here, we get m dot\xa0\n

b, and five, which are all these and you can\xa0\n

it's important to remember, values, let's see\xa0\n

clear so I just got a text document beside me cuz\xa0\n

forget which ones. So Am I clear? Obviously,\xa0\n

what do you call it the map. So we get an empty\xa0\n

this one like that is simply just going to tell us\xa0\n

how much time we had 10 minutes. So I actually I\xa0\n

maps. But if you want to think about this, and\xa0\n

that I just showed you be good exercise. And that\xa0\n

count all of those characters into a map. So\xa0\n

and then the value for that key is equal to the\xa0\n

times that character occurs, and try to do that\xa0\n

well, then you're definitely learning and you're\xa0\n

What I'm going to be doing is showing you some\xa0\n

and how you can do that with the information\xa0\n

everything in now, mixing it all together, and\xa0\n

way to kind of like apply all the knowledge that\xa0\n

computer problems. Because a lot of the time\xa0\n

you don't know how to kind of mix it all together.\xa0\n

I'm also going to be showing you some like useful\xa0\n

to talk about in previous videos. So yeah, that's\xa0\n

last video, I mentioned that a good exercise to\xa0\n

and you want to count or like a sentence or a\xa0\n

store them in like a hashmap and have the letter\xa0\n

appear. So I figured for any of you guys that\xa0\n

I would show you a solution here quickly to doing\xa0\n

make sure you pay attention, because this is\xa0\n

understand kind of how maps work and how you can\xa0\n

is I'm just going to create a string, let's\xa0\n

my name is Tim. And I am Cool. All right,\xa0\n

going to do that just because we're going to\xa0\n

human way to count this would be to go through\xa0\n

okay, so I have an L how many times the L appear.\xa0\n

for loops, like very efficiently in computing.\xa0\n

what we're going to do is we're going to loop\xa0\n

this is because if I try to do like for char\xa0\n

right. And in str you see we get this red line,\xa0\n

that we can do this is actually a cool method and\xa0\n

string into a character array for us. And the way\xa0\n

array. And this is if I literally just print this\xa0\n

System dot out dot print ln is simply just going\xa0\n

into a character array for us. So let's just run\xa0\n

printing this entire thing, but it's actually\xa0\n

loop through it. So you'll see in a second. Okay,\xa0\n

I'm going to see if that key already exists in\xa0\n

because that value is gonna be how many times it\xa0\n

m it already exists in the map, I'm just gonna\xa0\n

a new value. And you'll see what I mean here in\xa0\n

Key of x, then what I'm going to do is I'm going\xa0\n

and then the key is going to be x. And then what\xa0\n

cast int, if I need this, forgetting all my\xa0\n

should be interesting one second, saying I have to\xa0\n

I don't think we actually need to do this, but\xa0\n

and then we'll say, dot quotes. And for the key\xa0\n

character. And we're gonna say old plus one. Now,\xa0\n

the amount, so that's going to go up by one\xa0\n

what we're going to do is we're going to put\xa0\n

is going to be one because we just found the\xa0\n

is going to be x standing for the letter. And\xa0\n

to see the counts of all these letters. So to do\xa0\n

we're going to print the line, and we're just\xa0\n

this fast, and you might not really understand\xa0\n

through every letter in this string, we're going\xa0\n

map contains that letter already. So as a key,\xa0\n

simply going to add in a key, and it's going to be\xa0\n

of one. Because we just found it occurs one time,\xa0\n

if that key does exist, what we're going to do is\xa0\n

we're going to add one to that previous count and\xa0\n

it goes up to five. Pretty straightforward. So\xa0\n

there's eight spaces, we get a, there's three AC,\xa0\n

an account all of the different letters for\xa0\n

we could go through and count them like\xa0\n

it does look as though that is correct. So yeah,\xa0\n

it's really useful. And there's a lot of cases in\xa0\n

so the next thing I want to show you guys is\xa0\n

this is really just gonna take like 10 seconds.\xa0\n

you probably already guessed, but it's literally\xa0\n

So I just felt like I had to say this, because\xa0\n

forgot to say it. So to remove an element, you\xa0\n

want to remove like all the spaces, which actually\xa0\n

then if I do that. Interesting why it's not\xa0\n

it's because it's not because of character. My bad\xa0\n

space is different. Yeah, so that it actually\xa0\n

or from our map, whatever. Okay. Now, the next\xa0\n

sorting is something you typically want to do on\xa0\n

and I'm going to create a new array, an\xa0\n

with cases do like three, and let's do a\xa0\n

can get this to sort for us. Let's do negative\xa0\n

actually really easy, all we have to do is just\xa0\n

it takes two arguments. Now the first argument is\xa0\n

x, and then the other two arguments are\xa0\n

three arguments not to what these arguments do is\xa0\n

let's say, like this part of the list that's\xa0\n

way that we would do that is we would type one\xa0\n

we were going to 71234567. Funny enough, we will\xa0\n

but the thing is, it's going to work up but not\xa0\n

going to that seven, but it's only going to sort\xa0\n

this does, and I believe is actually just changes\xa0\n

Arrays dot sort, we just say Arrays dot sort. And\xa0\n

dot print ln, and we can print x. And let's see if\xa0\n

us. Okay, so we actually, man of course, we can't\xa0\n

loop to print these out just because when we try\xa0\n

or we get that message because that's the memory\xa0\n

and then we'll simply just print out I, it's got\xa0\n

instead of printing, ln, we're just gonna print.\xa0\n

separated. Okay, so let's run that. So there we\xa0\n

of the list for us, right? So we got 1234567, you\xa0\n

99 was not touched. Now, if you want to sort the\xa0\n

these indexes, you can just put x, in this case,\xa0\n

all the way up to eight. And yeah, so you could\xa0\n

or whatever, okay. And you can see, it's only\xa0\n

list for us, or in the array for us. So that's a\xa0\n

actually, in quite easily using just Arrays\xa0\n

like x equals Arrays dot sort. Because what it's\xa0\n

elements of x and swap them around, rather than\xa0\n

Where you're going to be introducing object\xa0\n

objects are and getting a little bit into\xa0\n

thing to really talk about is what is an object.\xa0\n

certain data type. So we know we have data\xa0\n

like all kinds of different things that we can\xa0\n

whatever, or hash map all that stuff, okay. And\xa0\n

classes if you want to say that. So whenever we\xa0\n

like scanner, SC equals new scanner, essentially,\xa0\n

to a scanner object, okay. And whenever we create\xa0\n

x equals five, we're essentially saying x\xa0\n

okay? These objects are what allow us to have\xa0\n

So you know how we can add integers together, or\xa0\n

and we can have like a bunch of different methods\xa0\n

object that we're using. So, for example, we\xa0\n

so SC is equal to a new scanner object that's\xa0\n

only use this dot next method on SC because it is\xa0\n

a little semi colon here, you can see that we're\xa0\n

int, because well, that method doesn't exist for\xa0\n

kind of understand what objects are essentially,\xa0\n

even just doing like string like, str equals,\xa0\n

str is actually equal to a string object with\xa0\n

the different types of objects, we have different\xa0\n

with the methods we can call in, that's just kind\xa0\n

create like objects and whatnot, that are specific\xa0\n

videos, okay, so it'll all start to come together.\xa0\n

things objects, essentially, that's like you have\xa0\n

something, you're creating an object of that\xa0\n

for now. So now let's talk about methods. So\xa0\n

are because I think I went through a very brief\xa0\n

essentially, methods are anything that you call on\xa0\n

to clarify, when instances when we're creating\xa0\n

we can say that we're creating FC is now an object\xa0\n

instance of scanner of like the type of scanner,\xa0\n

instance, instead of object, they're very similar.\xa0\n

when we call this dot next method, we call it\xa0\n

pointing to our scanner object. So our scanner\xa0\n

showed you before, if I tried to call that on, for\xa0\n

that doesn't work because that object doesn't\xa0\n

is anything really that's just like a dot, and\xa0\n

brackets, for example, if we had like, an array\xa0\n

just another string probably should have deleted\xa0\n

equals Hello. And I can do something like H dot\xa0\n

to us the length of the string. And again, this\xa0\n

not going to work on our SC, because well, what\xa0\n

can see that we're getting this red line here. And\xa0\n

this length method is not defined for a scanner\xa0\n

call methods. And you guys have already seen a lot\xa0\n

on different objects and different data types.\xa0\n

and objects, data types are kind of like what the\xa0\n

in in future videos. Just want to clarify in\xa0\n

can we create our own methods? Well, currently,\xa0\n

we're going to be creating methods inside of this\xa0\n

because it is it contains this method. And\xa0\n

this method automatically runs whenever we run the\xa0\n

we're going to have in classes we create in future\xa0\n

per se. But this is a method because a method is\xa0\n

the class is what's going to define like our data\xa0\n

now, there's actually somewhere that says public\xa0\n

So if you do like brackets like this, it has a ton\xa0\n

that we can use by calling them from within this\xa0\n

method within this main class, what we can do,\xa0\n

going to do for now, I'm going to show you why we\xa0\n

but it's a bit advanced right now. We're something\xa0\n

return type we want, which we'll talk about in\xa0\n

of our method. So in this case, I'm gonna say\xa0\n

Tim has your parameters, again, talk about that\xa0\n

in here. In this case, I'm just gonna say system,\xa0\n

you call up, it just says Tim, like that. Okay. So\xa0\n

method that we can call from anywhere within this\xa0\n

well. So what we need to do to call this method\xa0\n

type the method name since case by type Tim. And I\xa0\n

you see that we get is it running? one second\xa0\n

wasn't working, because we have this SC dot next\xa0\n

out for right now. And we will run this one\xa0\n

the screen. Now I know, I didn't really explain\xa0\n

what I've done here is I've created kind of like a\xa0\n

other programming languages, you might see this\xa0\n

means here is it returns nothing, okay, because\xa0\n

which I'm going to show or sorry, functions\xa0\n

to show you in just a second. So this stands\xa0\n

we're just going to do something in here. So in\xa0\n

screen. All right, now we have Tim. And this is\xa0\n

here to trigger this to run, right. So if I wanted\xa0\n

to print whatever string I passed to Tim, well,\xa0\n

and then let's just say str like that. And now\xa0\n

we have to actually pass it one piece of\xa0\n

be a string. Okay, so I'm going to show you right\xa0\n

here like this, okay, and we run the program. Now\xa0\n

like with a bunch of M's can see if we run this\xa0\n

this is called a parameter. So str is a parameter\xa0\n

call this function, we have to type in arguments\xa0\n

going to be when we get to the method. So anything\xa0\n

what this is known as where we're like triggering\xa0\n

so Tim is an argument. When we call this what's\xa0\n

saying like str equals Tim like the other\xa0\n

simply going to print to the screen. Whatever\xa0\n

right? Now we can actually do multiple parameters\xa0\n

I wanted to pass two pieces of information every\xa0\n

and X, okay? And now it means that I have to pass\xa0\n

that means we have to type an integer in here.\xa0\n

to do now we're going to say four. And we'll say\xa0\n

say i plus plus, we're just going to print this\xa0\n

okay, so System dot out dot print line, what's\xa0\n

got to do that, sorry. Okay, so now we pass an\xa0\n

to do is simply print this as many times as like\xa0\n

that we now we get Tim four times to the screen.\xa0\n

in here, the two arguments are Tim and four. And\xa0\n

x. And when we pass our information in str gets\xa0\n

and then in here, we can now use those values by\xa0\n

so I hope that makes sense. Now, in terms of this\xa0\n

next video. For right now, all this means is that\xa0\n

which is kind of what we're doing here, when we're\xa0\n

object that's like a class main, which you'll\xa0\n

how we can create our own methods. Again, we can\xa0\n

I wanted to talk about now. So all I'm going\xa0\n

I'm going to say this is public static. And in\xa0\n

whoever's calling this Okay, or wherever this\xa0\n

because this is what I'm going to return and\xa0\n

the method is going to give back to us. And I'm\xa0\n

going to take an integer x as our one parameter\xa0\n

return Yeah, okay. So you can see, it's already\xa0\n

a value in this method, because we typed in the\xa0\n

I'm going to do here is I'm simply going to return\xa0\n

is it's just taking a value x, and it's adding to\xa0\n

wherever we call it. So let's just do something\xa0\n

I'm going to say, system, dot out, dot print, ln,\xa0\n

then give it a number, in this case, six. Now, you\xa0\n

But essentially, what's happening here is we're\xa0\n

our argument is six, it's coming in here, and the\xa0\n

to return so back to wherever we call this x plus\xa0\n

a value, and we go, and we bring it up here. And\xa0\n

going to print eight to the screen. And you can\xa0\n

obviously, in methods like this, you're probably\xa0\n

adding to that shows you how we can return values.\xa0\n

like a string value. So public static string,\xa0\n

because I don't really know what to do. And\xa0\n

we have to return a string value. So what we could\xa0\n

point. But I think I need to put that in double\xa0\n

now is we're adding an exclamation point to\xa0\n

that. So if I call str here. Okay, so we'll I\xa0\n

we'll do str. And then inside our brackets, we'll\xa0\n

an exclamation point. And indeed it does. And\xa0\n

going to be going over classes when we talk\xa0\n

constructor methods, all that fun stuff, creating\xa0\n

to be kind of an advanced video. Don't if you've\xa0\n

able to follow along with it. But just know that\xa0\n

of Java. So if you guys don't understand this,\xa0\n

ask me some questions, leave a comment down below.\xa0\n

have to understand this before you can really\xa0\n

for kind of all languages, but Java, especially\xa0\n

to understand classes and how to create classes.\xa0\n

so far, we've been working in this class. Hold me\xa0\n

class, all it's doing for us, is just running\xa0\n

And that's what we have this public static void\xa0\n

we click this little green Run button. Okay, so\xa0\n

have some methods that I've added in here that we\xa0\n

I'm going to do now is I'm going to create my\xa0\n

going to start coding. So to do this, we're going\xa0\n

tutorial, one for me, and I'm going to go new and\xa0\n

now I'm going to give my class a name. Now, for\xa0\n

And yeah, you guys can create whatever you want.\xa0\n

since you guys are most likely new to classes.\xa0\n

public class dog. And you can see we open up in\xa0\n

in Java, we have to actually create a new file\xa0\n

makes it really easy to navigate between different\xa0\n

just have all your classes in one file. Okay, so\xa0\n

class dog. So what does this What does this mean?\xa0\n

data type. And whenever we create an instance of a\xa0\n

doing is we're just using all the information\xa0\n

you can almost think of it as like a blueprint\xa0\n

fall for us? Like, why are they useful? So I'm\xa0\n

right? So I want to create five dogs, okay, I want\xa0\n

I want each dog to have an age. And I want to,\xa0\n

print out each dog's name and age and like a nice\xa0\n

do that. If we went back into main here, what we\xa0\n

here is we could just type a bunch of answer you\xa0\n

and that's dog one's age, we say int dog two,\xa0\n

create 10 variables, five for the age and five\xa0\n

we could print out each one each time. But\xa0\n

I wanted to have like 10,000 dogs? Well, what\xa0\n

like lists to create or lists or raised to create\xa0\n

it doesn't look as good in our actual coding. So\xa0\n

and you'll see how we can kind of accomplish this\xa0\n

have attributes, okay? Now attributes are kind of\xa0\n

this case, we want to have two attributes in our\xa0\n

the age to create our attributes. And so the first\xa0\n

right at the top of our class, we're going to type\xa0\n

data types. In this case, we can say string, and\xa0\n

name, okay, and this all we have to do, we're\xa0\n

we're going to have the attribute name, and\xa0\n

on in our program. Okay, we can also do private\xa0\n

is going to obviously represent the dog's age.\xa0\n

we would, again, type private. And we could keep\xa0\n

is this private keyword? And why do we have public\xa0\n

keyword does is it ensures that this name and\xa0\n

meaning that if I tried to do something over\xa0\n

from this class, I wouldn't be allowed to do that.\xa0\n

attribute, you can't access that. Why do we do\xa0\n

but we can also create public attributes as well\xa0\n

if I wanted my things to be public, I could put\xa0\n

we're going to use private, and it's best practice\xa0\n

for methods, which you'll see in a minute. Okay.\xa0\n

constructor method. Now this, you typically\xa0\n

create multiple, what this is going to do is it is\xa0\n

dog class. And the way we create this constructor,\xa0\n

class is we're going to do public. And we're just\xa0\n

so excuse me as a public dog, like this, okay.\xa0\n

everything's fine. And in here, we're going to\xa0\n

need to be passed in whenever we're creating a\xa0\n

nothing in here, when you create a dog object, all\xa0\n

object. You don't need to give any information and\xa0\n

to create an age and a name with our dogs. So what\xa0\n

and int, age, okay, just meaning that whenever we\xa0\n

and we need to give it an age. Now what I'm going\xa0\n

attributes equal to whatever we pass in. Okay? So\xa0\n

keyword and it's, the keyword is this, it's kind\xa0\n

just like saying this is a keyword and pointing\xa0\n

then I'm doing this dot name is going to be equal\xa0\n

age. So what is this, this this keyword actually\xa0\n

the class, okay? So when we type this, it is going\xa0\n

private attributes. And in this case, we have an\xa0\n

reference things that are a part of the specific\xa0\n

okay, and I'm going to explain more and more\xa0\n

in like small steps. Okay. So now that I have this\xa0\n

one more method, and then we can actually start\xa0\n

going to do now is I'm going to create another\xa0\n

I'm not going to return anything, so I'm going\xa0\n

speak. And what this is going to do is it is\xa0\n

to the screen. So I'm gonna say system, dot out,\xa0\n

all we're gonna do is we're gonna say I am, and I\xa0\n

we'll say this dot name, okay? And we'll say plus,\xa0\n

plus years old, okay? So suddenly gonna say like\xa0\n

years old, not great grammar, but that's fine. So\xa0\n

Or how do we use this class? Well, from our main\xa0\n

you know, we can delete all these, we don't need\xa0\n

we can actually create a object and to do that of\xa0\n

and we're gonna give it a name. In this case,\xa0\n

And then remember that we have to give dog some\xa0\n

have the name, and we have the age. So what we\xa0\n

age. In this case, we can type 10. And I'm going\xa0\n

we're looking good. So our dog's name\xa0\n

so that's great. Let's run the program, make\xa0\n

what I want to do is I want to use that\xa0\n

I'm going to do is I'm going to type Tim, which\xa0\n

dot speak like this, okay, semicolon. And let's\xa0\n

I am four years old. So the way that this worked,\xa0\n

and the instance was named Tim, and it referenced\xa0\n

instance, we said, okay, so this instance, this\xa0\n

and a name of Tim. All right. So it stored that\xa0\n

our private int. And then later on, when we\xa0\n

Okay, well give me the instance you're calling\xa0\n

we're gonna say okay, so Tim, what's Tim's name?\xa0\n

Tim, what's its age, its age. That's four. So\xa0\n

create multiple dog objects. So let's copy this\xa0\n

dog objects. I'm gonna say this is Bill, and he\xa0\n

11. Okay, let's copy this and keep naming the\xa0\n

and then we can simply call the speak methods on\xa0\n

Alright. And just to prove something, I'm gonna\xa0\n

why I do that in just a second. Okay, so let's run\xa0\n

I'm Bill I'm seven. Then go on and you can read\xa0\n

again, it still retains its age and its name.\xa0\n

Like this is not one variable. We actually now\xa0\n

we have bill we have Bob. And there's specific to\xa0\n

object okay. So that means that we can hold like\xa0\n

and we can have like infinite amount of instances\xa0\n

I think I'm going to talk about quickly. I\xa0\n

Let's create some more methods in here and see\xa0\n

about constructors because we're only at like,\xa0\n

going to create a another method. And I'm going to\xa0\n

And in this case, we'll say int, get H. All right.\xa0\n

the age to, let's see a return statement to\xa0\n

all we'll say it will return this dot h. Now,\xa0\n

I want to get the age of one of my dogs, right?\xa0\n

I don't know what it is I want the age. Well, we\xa0\n

we'd be able to do like Tim dot age, right? Now\xa0\n

lines. And it says the field dog dot age is not\xa0\n

So it's not letting us see it from over here\xa0\n

method only within this class, can we actually\xa0\n

what we can do is we can call Tim dot get age like\xa0\n

we say like, and x equals, I'm gonna say system,\xa0\n

So now if we run this, we can see that we get\xa0\n

of the screen. Now we can actually do the same\xa0\n

change the age at some point, maybe Tim got a year\xa0\n

another method in here, this case, we're going\xa0\n

and we don't need to enter this time, because\xa0\n

going to return to say public void. And we'll say,\xa0\n

because we need to know what we're going to set it\xa0\n

just like we've done up here, is the exact same\xa0\n

the method set age. So now, if I want to change\xa0\n

set age, and we'll give it a value of 10. Then\xa0\n

What's gonna happen now sorry, guys, I'm a bit\xa0\n

I'm going to do is, oh, what's your air timeouts\xa0\n

second here, sorry, public, let's try this. Insert\xa0\n

here. Oh, okay. That's why I can't do I can't set\xa0\n

age by about on that guys. We do speak, we can\xa0\n

and we've changed from the age of four. So that's\xa0\n

later on within the the class. Okay. Now I want to\xa0\n

and show you what this is. Okay, so I'm gonna\xa0\n

it. Okay. And we're going to call this add to it,\xa0\n

but just, it's just an example. Okay. And in here,\xa0\n

but we're going to return we're going to\xa0\n

this is a private method, meaning that it\xa0\n

So say I wanted to use this add to, maybe I\xa0\n

and just do a little semi colon. And there we go.\xa0\n

no issues with that. Okay. And that's how you use\xa0\n

I can easily every time we initiate the dog, call\xa0\n

class, you don't need to do like something dot\xa0\n

really visible within here, right? Now, what would\xa0\n

so add two, so we'll say Tim, dot add two like\xa0\n

a red line and says, This is not visible, you\xa0\n

So in today's video, we're going to be going over\xa0\n

this is going to be how we can inherit methods\xa0\n

new class, and then override methods and all kinds\xa0\n

save you a ton of time. And yeah, so let's get\xa0\n

this dog class that we created in the last video.\xa0\n

at least in this video, the problem is, I want to\xa0\n

class, except in the speak method here. Instead of\xa0\n

name is what I write right Just want to change\xa0\n

But other than that, I want all of this to be\xa0\n

is, well, we just take all this, copy it, put it\xa0\n

this to be what we want. Well, we could do that,\xa0\n

are like 1000s, and 1000s, of lines long, ideally,\xa0\n

typing like the same thing a bunch of times,\xa0\n

read. So what we're gonna do is we're going\xa0\n

going to create a new class, I'm gonna go new\xa0\n

cat, alright. And they'll just click Finish like\xa0\n

whenever we do this inheritance, what we can\xa0\n

all of the methods, everything from this dog\xa0\n

we can type extends, if we spell it correctly,\xa0\n

Now what this is going to do is it is going to\xa0\n

class. So this is known as our superclass because\xa0\n

known as our subclass. So we have, you can also\xa0\n

could be also called a parent class, all right.\xa0\n

getting everything from there, but then it's going\xa0\n

few methods to it. So typically, you start off\xa0\n

and then your child classes or your drug classes\xa0\n

same thing, just everyone likes to use different\xa0\n

modifications to them, and kind of work based\xa0\n

class. Okay. So what we need to do when we first\xa0\n

us, we need to use the constructor for dogs. So\xa0\n

the same constructor, otherwise, all this stuff.\xa0\n

to work unless we set up our class when we first\xa0\n

gonna do is I'm actually just going to click on\xa0\n

this constructor for us. Now, I could have typed\xa0\n

going to do. So since in our dog class, we get\xa0\n

we have a constructor inside of our cat class that\xa0\n

explicitly call our superclass constructor, which\xa0\n

this formation or this syntax super. And then we\xa0\n

doesn't stop us from being able to type in other\xa0\n

I could do something like int, and I don't know\xa0\n

should get, this works perfectly fine. And we can\xa0\n

So we say private, or no, I'll just say food.\xa0\n

here, we can go ahead, and we can just type this\xa0\n

perfectly fine. And now we're gonna have, since\xa0\n

we're gonna have name, and inside of this cat\xa0\n

works just fine. Okay. So just to know, let's\xa0\n

through pretty quickly. But all of these methods\xa0\n

cat class, because we'll we're inheriting we're\xa0\n

cat class when we first extend it, and do nothing\xa0\n

we start changing a few things in here, it's gonna\xa0\n

this functionality. So we still have the attribute\xa0\n

because we're gonna call this constructor method,\xa0\n

here. So we call this constructor. So we set up\xa0\n

we have get age, we have set age. Now before\xa0\n

you. So if I go to main here, and I just\xa0\n

CIM equals new cat. And remember, we have to give\xa0\n

because that's what we typed in. So for name, we\xa0\n

let's say they get 100. I don't know grams of food\xa0\n

Okay. Now I can use this speak method on Tim. So\xa0\n

in my cat class, there's no speak method. But\xa0\n

we can use it. So I'll prove again to you\xa0\n

and that works perfectly fine. So now remember\xa0\n

something else, I want to change it. So how can we\xa0\n

this is to just rewrite the method in here because\xa0\n

whatever's in the dog class. So the child class\xa0\n

Whenever there's something the same in here, it\xa0\n

whatever is in the dog class. So I do public, void\xa0\n

other one. All right, and in here, I change I do\xa0\n

just gonna say, system dot out, dot print ln. And\xa0\n

name is what to say plus this dot name. And you\xa0\n

get fed. Let's see here, plus this dot food.\xa0\n

what's the issue here? Change visibility of name\xa0\n

here. Okay, this just needs to be sorry, public\xa0\n

actually able to see these attributes, because\xa0\n

our cat class. So we just need to change them to\xa0\n

to use them within our speak method, we can also\xa0\n

to talk about near the end of this video. Okay, so\xa0\n

get into protected. But let's see what happens.\xa0\n

my name is Tim and I get fed 100. Okay. And that's\xa0\n

since we wrote it again, in our cat class, and\xa0\n

simply going to take this one, and we're going to\xa0\n

obviously, when we're doing inheritance,\xa0\n

we can add more stuff, and we do whatever we want,\xa0\n

say public void, I don't know, eat. And in this\xa0\n

like as how much they're eating. And we can say\xa0\n

subtract from it however much they ate. And then\xa0\n

going to be seen in the dog class, right? So we\xa0\n

all the stuff we do in the cat class is not going\xa0\n

dog does not extend cat, right. So it's kind of a\xa0\n

branches off and we could have other things extend\xa0\n

the cat class. And we can just keep going and\xa0\n

extending. Also known as like inheritance, right?\xa0\n

to show something called multiple constructors,\xa0\n

a class, we want to be able to pass it like a\xa0\n

class differently, right. So for example, my\xa0\n

if however, I only wanted to give it a name and\xa0\n

they don't have to be mutually exclusive, right?\xa0\n

set it up, or I could give it just two. And to\xa0\n

So I'm going to do the exact same thing as above,\xa0\n

out one of the parameters here. Okay, so Second\xa0\n

and name and H guy. And you'll see no red lines,\xa0\n

doing here is we're giving it another way to set\xa0\n

our attributes and set up the cat class. So we can\xa0\n

or three arguments, or we can call it using two.\xa0\n

using one, we're only using zero. So let's do\xa0\n

work. Okay, so if I do string name, and then int,\xa0\n

should just get rushed. actually get rid of this,\xa0\n

I'm going to give name. But what about age? What\xa0\n

know. How are we going to set it up? If they only\xa0\n

they don't give us an age, then we should just\xa0\n

let's do that I'm going to put in zero, just hard\xa0\n

for example, they only want to give us a name,\xa0\n

of zero, they want to give us a name. And in age,\xa0\n

should do in here, if they give us a name and age\xa0\n

don't know, maybe let's give it a default value of\xa0\n

eats, we're just going to assume that they eat 50.\xa0\n

know when I was like default parameters. If they\xa0\n

a value for that. So that everything still works\xa0\n

the three different ways that we can create a cat.\xa0\n

we'll give it a name. So we'll say Bob, and we'll\xa0\n

works fine. Again, this defines a cat right\xa0\n

So let's do this one more time. And in this case,\xa0\n

this One do, like the name Joe. Alright. And\xa0\n

like Bob speak. And we could do, Joe does speak.\xa0\n

can define a cat. Okay, so Meow, my name is Joe, I\xa0\n

on like that. So again, when we have one, now we\xa0\n

we should probably give them food as well. So we\xa0\n

default value for how much they get fit. So that\xa0\n

And now I'm going to talk about protected values.\xa0\n

similar to private and public. But they're, they\xa0\n

use the protected keyword instead of public\xa0\n

here in my dog class, I'm going to go up and\xa0\n

things that are within the same package, or are\xa0\n

pretty much like name. Okay, so that means any of\xa0\n

package are able to see this. But if I had another\xa0\n

Java programs, anything in there would not be able\xa0\n

what do you call it whenever we're creating\xa0\n

Wow. Okay. We're going to want to use a protected\xa0\n

our attributes so that we can change them access\xa0\n

for these methods, it's fine. They're public\xa0\n

well, if we didn't want another package to be able\xa0\n

right, if we create a private method here, I'm\xa0\n

if this is going to allow us to use this\xa0\n

let me know which one I changed. Get age.\xa0\n

this is gonna work. Yeah. So again, this is not\xa0\n

made it private, right? If we made that protected,\xa0\n

of the package. Now, I want to try this though,\xa0\n

our cat class. So if I do, for example, when I\xa0\n

so this isn't working as well. Which means\xa0\n

we have to make sure they're either public or\xa0\n

time you really get to create private methods\xa0\n

using the map that so for example, maybe you're\xa0\n

from within the class and you don't want anyone\xa0\n

you create a private method to do that, because\xa0\n

So in today's video, we're gonna be going over\xa0\n

So you may have seen that we've used static\xa0\n

actually, I'm going to delete all this. It says\xa0\n

I guess I haven't really explained what static\xa0\n

this video. So let's get started and talk about\xa0\n

called attributes games, we have these two\xa0\n

our dog. So when we created multiple dog objects,\xa0\n

and other dogs were not affected when we change\xa0\n

unless that dog was that obviously, right.\xa0\n

of different values that are specific to different\xa0\n

sometimes, we want to have variables that will\xa0\n

we can change them in one instance. And if we do\xa0\n

other. Now, those are known as class variables,\xa0\n

are like kind of attributes, okay? The way that\xa0\n

something like this. So yes, let's say protected\xa0\n

in my dog class, I deleted a bunch of stuff out\xa0\n

And I still have the cat class, but it's just\xa0\n

say protected static int count equals zero. Now,\xa0\n

doing here essentially is we're creating a class\xa0\n

which is protected. Okay, I know it's a lot\xa0\n

do so what this is actually going to do is it's\xa0\n

which means it's not going to change for each\xa0\n

it'll change like that. All together, right? So\xa0\n

this static keyword is going to allow us to do.\xa0\n

variable is a part of, we just care that it's a\xa0\n

this value x, well, I do need still need to call\xa0\n

then or actually, I'm gonna say plus equals one,\xa0\n

here, consist, I feel dogs should be accessed in\xa0\n

Okay, what I'm doing here, sorry, one second,\xa0\n

this count, because I want to keep track of how\xa0\n

know, like, see how many dogs have been created,\xa0\n

then figure that out. Alright. So what I'm doing\xa0\n

actually work, is I'm calling dog count. Because\xa0\n

static variable, class variable, whatever you\xa0\n

what instance I'm changing it on, because it's\xa0\n

actually use the name of the class to change it.\xa0\n

I'm not sure if you guys read that. It said we\xa0\n

it's a static variable. So I could, however, call\xa0\n

Because this will is an instance of the dog class\xa0\n

but it's much better to do dog count, like plus\xa0\n

you that this does indeed actually work. I'm not\xa0\n

objects here. Say a Tim or dog. Tim equals new.\xa0\n

say 10, and score nine for age. And we'll just\xa0\n

maybe, say, Bill, and that is new dog name. Bill,\xa0\n

is protected, I can actually access it from me.\xa0\n

to print count out first of all, is I'll prove to\xa0\n

keep thinking, we're in Python here. And I'll just\xa0\n

and just see what we get as a value First of all,\xa0\n

is indeed working, because well, when we added one\xa0\n

it would just be one. But anyways, and if I want\xa0\n

dog dot count, let's say equals like seven. Okay?\xa0\n

count, we get seven. Now I'll show you two. If I\xa0\n

answer. So you can see we get seven. Even though\xa0\n

count. Since it's a dog part of the dog class,\xa0\n

obviously, within 10 as well. Okay, so that's kind\xa0\n

talk about static methods. Okay, so this was a\xa0\n

a class variable just because it's what I'm used\xa0\n

we're gonna talk about static methods. And what\xa0\n

way that this works, but is a little different.\xa0\n

void, display, okay. And in here, all I'm going to\xa0\n

I'll just print. I am a doc. Okay. So what this is\xa0\n

in here, what's going to happen essentially, is\xa0\n

actually just call this on the dog class. So I\xa0\n

since it's a static method, this works fine. And\xa0\n

to if this was a regular method, so let's just\xa0\n

here. So public void, and we'll say, display to\xa0\n

it word for word in here, just to show you the\xa0\n

to do dog dot display too. You can see that we're\xa0\n

this static because we need an instance to call\xa0\n

create a dog object. And then we can use that\xa0\n

this dot display too. And that works fine because\xa0\n

this represents the instance that we're using. So\xa0\n

simply using dog but the thing was static is it\xa0\n

values are our attributes, right? So if I wanted\xa0\n

I can't do that for a static method like, I can't\xa0\n

work. Because if you think about it, well,\xa0\n

there's no instance, we're just simply calling\xa0\n

age to look for, or what name to look for. So the\xa0\n

care about the instance. And we just want to do\xa0\n

class. You can almost think of it as a function if\xa0\n

that is ideally how static works. So whenever you\xa0\n

about the like the instance, you don't care about\xa0\n

way you can call it without having an instance. So\xa0\n

I'll quickly go over what this void does one\xa0\n

in our functions, we can return values, when you\xa0\n

anything, we're just going to do something,\xa0\n

or in this case, printing something out to the\xa0\n

the user, but we're just not returning\xa0\n

So in today's video, we're gonna be going over\xa0\n

a string representation of different objects.\xa0\n

these are really useful. And I guarantee you guys\xa0\n

objects, like maybe like point objects, or like\xa0\n

to compare, without having to make things too\xa0\n

right. So what I'm going to do here, and what I've\xa0\n

set up. And this is just what we're going to work\xa0\n

in previous videos were already like finished, and\xa0\n

And currently the only attribute the student\xa0\n

I've just created a few different students.\xa0\n

out to the screen. So that's why I have that\xa0\n

we just create a name for a student. Now I just\xa0\n

like comparing objects intuitively right? So say\xa0\n

right? Like if I want to see if they were equal to\xa0\n

So what I would do is I'd say like Joe is equal\xa0\n

know, their names are not the same. So they're\xa0\n

that would be correct, but not for the reason that\xa0\n

have Joe and Bill compared to each other. So watch\xa0\n

right? So you'd think well, these would be\xa0\n

right? Because they have the same name. But watch\xa0\n

why is that? Exactly? Well, pretty much we\xa0\n

right? So like Joe, and Bill, the computer\xa0\n

what it does is it compares the actual object. And\xa0\n

a new object. And here we're creating another new\xa0\n

two different objects, like in memory, okay, so\xa0\n

entities. And they're completely unique. Although,\xa0\n

names, and we can do things. These need to be\xa0\n

actually saying, well, we're going to look and see\xa0\n

are not. Now that's useful in some cases, because\xa0\n

same object. But in other cases, we want to see if\xa0\n

So in this case, we probably want to compare the\xa0\n

same. And in that case, we would say, Well, yes,\xa0\n

Yes, they are, they are the same, right? When we\xa0\n

do now is I'll delete this. Let me show you how we\xa0\n

class, I'm going to add a method, okay. We'll call\xa0\n

we're gonna say equals, and then here, we're gonna\xa0\n

then we'll go like that. And there we are. So what\xa0\n

our students, okay, we're going to pass another\xa0\n

right? So we're going to call this dot equals on\xa0\n

going to give it another student, and then we're\xa0\n

say we're going to check the same? Well, we're\xa0\n

going to do is I'm going to say if, and then we'll\xa0\n

here as well. always forget about those. If this\xa0\n

other dot name, then what we'll do is we'll simply\xa0\n

names are not the same, what we will do is we\xa0\n

we need to do for our dot equals. So now, what's\xa0\n

we'll call this we'll check name, and then we'll\xa0\n

if it is, or if the same will return true,\xa0\n

try this out. So these two are the same names.\xa0\n

I guess we will put a bill. So let's run this.\xa0\n

if I change bill, back to say, Bill, then we\xa0\n

now we officially have something checking for\xa0\n

more kind of ones like this, like equals grade,\xa0\n

how we can check for equality between objects.\xa0\n

Obviously, if you had a student with a bunch more\xa0\n

other stuff like that, or like a last name, you\xa0\n

Or you can just kind of customly do it the way\xa0\n

the same, right? Okay, so the next thing I want to\xa0\n

than sign or less than sign, right? So I want to\xa0\n

greater than Tim. And we should intuitively like\xa0\n

can't really show you like a way to do it here cuz\xa0\n

than bill. Yeah, see, that just is undefined,\xa0\n

is we're going to use a method called compare to,\xa0\n

to, what do you call it, sir, we have to implement\xa0\n

at the top of our class, I'm gonna spell it\xa0\n

then in here, we're going to do student. Now what\xa0\n

is we're actually implementing something called\xa0\n

about in I think, like two videos from now. But\xa0\n

we have to use for the class to work. So when\xa0\n

we're allowed to bring in a method that is going\xa0\n

we'll do now, is we will say, public and actually,\xa0\n

ins and compare compared to, and then in brackets\xa0\n

this will be other, we'll put our brackets here\xa0\n

return some kind of integer. And I'll show you how\xa0\n

screen, so don't mess this up. Okay. What I'm\xa0\n

dot compare to, and in this case, we're going to\xa0\n

will be other dot name, okay. So essentially,\xa0\n

this name to this other name, and it's going to\xa0\n

away they are, right? So it's, it's kind of hard\xa0\n

it from over here. And you'll see what I mean.\xa0\n

to bill. Let's see what we get. We get a value of\xa0\n

bill by a distance of eight, meaning that\xa0\n

they are eight away, I believe, okay. So if we\xa0\n

we do is we check if this integer value returned\xa0\n

that's going to tell us true if Joe is greater\xa0\n

and we get true. Now, let's see if we compare Joe\xa0\n

alphabet, so we get a value of false, okay, and\xa0\n

can see exactly what we're actually getting as a\xa0\n

far away j is from T one, we're comparing them and\xa0\n

if we wanted to check if Joe was less than 10,\xa0\n

in this case, we get true. So that's a really easy\xa0\n

that compare to method Okay, so like this a public\xa0\n

implement comparable students. And then you can\xa0\n

the last thing I want to show is a string\xa0\n

what happens when I just want to print out\xa0\n

him. And maybe ideally, I'd like to see like\xa0\n

look what we get here, we get tutorial, one dot\xa0\n

What this is printing is actually the memory\xa0\n

are actually stored in memory, in RAM in like\xa0\n

you guys. But anyways, this is like the address\xa0\n

this is what it's actually using to find Tim and\xa0\n

us where it is in the tutorial one, like folder,\xa0\n

we this does not help us as programmers at all\xa0\n

and gives us some valuable information. So\xa0\n

nother method here, that's going to change this\xa0\n

but this is exactly what I'm going to use, we're\xa0\n

like this, okay. And what we're gonna do in here\xa0\n

of our object. So what we can do essentially, is\xa0\n

what we're going to use to represent our object.\xa0\n

like this, okay, and just follow me for one\xa0\n

and then we're gonna add this store name. And then\xa0\n

you'll see when I printed out to the screen,\xa0\n

then Tim. And this is just simply telling us that\xa0\n

and the name value is Tim. Okay. And we could\xa0\n

double brackets around this name, if we want\xa0\n

okay? Now for our purpose, I'm just going to\xa0\n

And you can see again, when we print this, it\xa0\n

I'm not actually calling this two string method,\xa0\n

Java actually knows that when we have this two\xa0\n

a string, right? So when we try to print it, it's\xa0\n

Okay. So now, what we can do is we also just\xa0\n

I could just call.to string like this, and I\xa0\n

the exact same way as before, you can see we get\xa0\n

however you'd like. In some cases, like say your\xa0\n

their name. And then after you have like an array\xa0\n

Now, inner classes are pretty, pretty easy,\xa0\n

class inside of another class or inside of a\xa0\n

go along. But since we already know all about\xa0\n

I'm not gonna explain too much of it, I'm just\xa0\n

of inner classes in different ways. So I'm gonna\xa0\n

that I've already created. can see on the side\xa0\n

intercourse right now, in a class is just gonna\xa0\n

make this a public void display. And in here, all\xa0\n

to the screen. So we know that we're actually in\xa0\n

inner class, okay? And what's our error here,\xa0\n

mistake somewhere here, one second guys. Oh,\xa0\n

know why I added those anyways. Okay, so this\xa0\n

I'm going to create another method that's going to\xa0\n

is actually contained within the outer class,\xa0\n

can only actually access it from within our class.\xa0\n

means we must need a method in our class to do\xa0\n

inner, and in here, we're going to take nothing,\xa0\n

instance of our inner class and just display Okay,\xa0\n

new inner class like that. Okay? And then all\xa0\n

make sure that this is working. Okay, so now our\xa0\n

have these void inner and all that does is create\xa0\n

screen. Again, note that this is private meaning\xa0\n

okay, so now if I go to my main dot java, I can\xa0\n

we can see this. So first of all, what I have to\xa0\n

call that inner class. So outer class out equals\xa0\n

that I don't have any constructors here, meaning\xa0\n

outer class or my inner class when I first call\xa0\n

brackets. Okay. So now if I want to see my inner\xa0\n

enter. Ok. So we'll call that method to create\xa0\n

run quickly here. And we can see we get this is\xa0\n

Now I'm just going to make this public. Now I'm\xa0\n

of the class. So right now what we need to do is\xa0\n

then we need to call the method inner, to be able\xa0\n

was private. But now that it's public, we should\xa0\n

class. So the way that we do that is we still\xa0\n

class is defined within outer class. So we need to\xa0\n

right? As we did that, we have outer class.\xa0\n

dot inner class, okay. And we'll just call this\xa0\n

going to be our instance of outer class dot. And\xa0\n

believe this is correct. But I guess we'll see\xa0\n

new new outer dot inner class. And let's see what\xa0\n

package out. Interesting one second, guys. Okay,\xa0\n

like this, what we need to do is we need to do dot\xa0\n

new instance inside of this right of outer class\xa0\n

we've created this i n, which is an object, which\xa0\n

n, which is an instance of inner class, right to\xa0\n

so if we run this, see, this is an inner class,\xa0\n

you can get access the in a class. Now, right?\xa0\n

would I do this, because now it's just like a ton\xa0\n

don't really care about like this instance, and\xa0\n

it. So in that case, this would make more sense to\xa0\n

methods than just one you're gonna be using. Okay?\xa0\n

show creating this kind of inner class. So I'm\xa0\n

actually create these inside of methods, which are\xa0\n

we want to use a class and we don't want to have\xa0\n

Okay. So we have this public void, enter. So I\xa0\n

don't even leave in a class right now. And let's\xa0\n

and I can say, we can do public private, in this\xa0\n

to class in a class. And then here, yes, that\xa0\n

So we'll say, public void display. And now that I\xa0\n

my other code, but whatever, get some practice\xa0\n

should probably be a T, we will just type inner\xa0\n

fine. Whenever we call this void inner, then we\xa0\n

an instance of it, and we're going to display it.\xa0\n

just kept all that code. That's fine. Why is this\xa0\n

new and outer class and brackets. And then in this\xa0\n

so now we can see what should happen is again,\xa0\n

and we get in our class. Now pretty much you can\xa0\n

saying this is public or private is just because\xa0\n

we're gonna have to call this void. So there's\xa0\n

like private or public But again, like if you\xa0\n

or Oh, actually saying you can't do that. So I\xa0\n

inside of this void, you're only gonna be able\xa0\n

in really giving it like a public or private\xa0\n

we can still do public and private methods,\xa0\n

be using those methods, right. So you can see\xa0\n

inside of the, the voids inside of inner,\xa0\n

it wouldn't work. Because this class is only\xa0\n

interfaces are either unique to Java, actually,\xa0\n

languages, but they're somewhat similar to\xa0\n

And anyways, you guys will see as we go through\xa0\n

they're an important part of Java, so we need to\xa0\n

is we're gonna create a new interface.\xa0\n

we're just gonna right click on tutorial one,\xa0\n

obviously, we're gonna click interface. Now,\xa0\n

example that I'm going to be doing. So we'll click\xa0\n

no like, you don't have to package generate\xa0\n

now we have an interface called vehicle. So\xa0\n

something that is completely abstract. Now, this\xa0\n

not actually going to like you can't create an\xa0\n

is to be inherited from. So if we have a class\xa0\n

car could implement the interface and use it.\xa0\n

interface it just here, so that we can implement\xa0\n

So inside of our interfaces, and you'll see\xa0\n

and we actually don't define anything inside the\xa0\n

a method in interface, and I'll just make one\xa0\n

void, speed up. And we'll take as a parameter\xa0\n

I don't put those, the brackets, I don't do\xa0\n

this. Now, you could see that this is completely\xa0\n

it just defines the fact that this method exists.\xa0\n

don't give it a value, that's kind of what we're\xa0\n

car class. And you'll kind of have to go through\xa0\n

when you create a method, just know that you don't\xa0\n

this method will exist in any of the classes that\xa0\n

methods here and already call it like a attribute.\xa0\n

interface because the easiest way to understand\xa0\n

gonna slow down. And we'll have to go change gear\xa0\n

gonna implement a vehicle from a car and you guys\xa0\n

and then I'm gonna add a attribute. Now, any\xa0\n

whatever you guys want to call them, they have\xa0\n

in the last video, but final means that it's\xa0\n

we can't change this value. So I'm going\xa0\n

just say five. Okay, actually, or let's just go\xa0\n

saying that each thing we're using is going to\xa0\n

interviews equals five, that still works, but it's\xa0\n

so just make sure whatever you're doing\xa0\n

to have like variables or whatever that you\xa0\n

they must be final. Okay. So right now, we've\xa0\n

which is just called gears. Okay, so how do we\xa0\n

that work? Well, the way we use it is we've typed\xa0\n

and then the name of the interface in this case,\xa0\n

getting a red line, we're getting an error.\xa0\n

implement it but car saying the type car must\xa0\n

so that means that since we've defined these three\xa0\n

we have to define them inside our car class. So\xa0\n

one of the interfaces, we have to define them,\xa0\n

And if we call them well, we have no idea what\xa0\n

right? So we're gonna have to create a void\xa0\n

void Change was calling viewers or gear.\xa0\n

and then it's gonna have to take one parameter. In\xa0\n

gear do we want to change? Okay? And then we're\xa0\n

private int gear, because we're going to define\xa0\n

so now we're gonna go to and make another the\xa0\n

we need speed up. So we'll say public void speed\xa0\n

speed are actually not speed, we're going to go\xa0\n

by, and then we'll do one more. So public void,\xa0\n

change. And there we go. So this now we're getting\xa0\n

methods that were abstract over here. Okay, now,\xa0\n

just like, if we wanted to use it, we could,\xa0\n

I'm actually gonna create another private int, I'm\xa0\n

now is I'm going to just just fill up these,\xa0\n

say when we change gear, we're just gonna say,\xa0\n

it to. And then for speed, I'm gonna say, this\xa0\n

and then down here, we'll say this speed minus\xa0\n

now what we're gonna do is we're actually just\xa0\n

works. So we've implemented the things we need to\xa0\n

going to do is we're going to just create another\xa0\n

like a display method so that we can display our\xa0\n

And inside of here, I'm just going to print out a\xa0\n

print, ln, and in this case, we'll just say, I am\xa0\n

let's say going and how fast we going we're going\xa0\n

little kilometers per hour, so let's do that. And\xa0\n

is. So this stuff stuck here. Perfect. Okay,\xa0\n

interface vehicle, okay, and we have our car. So\xa0\n

objects, we'll say car. I don't know, let's say,\xa0\n

what we're gonna do is we're gonna say car dot.\xa0\n

up, and let's maybe change it to 10, we'll add 10\xa0\n

have to make this speed default at like zero, and\xa0\n

Otherwise, you're gonna run into an air arshi\xa0\n

Can you just change that to one? Okay, perfect.\xa0\n

gear, and let's just change the gear to Okay. And\xa0\n

Ford dot display. Perfect. Okay, so let's run this\xa0\n

am a cargo in 10 kilometers an hour, and I am in\xa0\n

implemented all that stuff from our interface\xa0\n

some cool things, we can add into our interfaces\xa0\n

example, you've used a bunch of interfaces with\xa0\n

And now what you want to do is you want to add a\xa0\n

from it, well, what you could do is you could do\xa0\n

like this. And then you could go into every single\xa0\n

be whatever you want. But if you want the method\xa0\n

use something this is why interfaces are kind of\xa0\n

and then maybe in this case, void, and let's just\xa0\n

just to make it easy. What we'll do here is we'll\xa0\n

this from any of the classes that inherit our,\xa0\n

say system, dot out dot print, ln, in this case,\xa0\n

creative. How did I just spell system? And I okay,\xa0\n

System dot out dot print ln default method.\xa0\n

this car class, we can use that default method.\xa0\n

then we want to do the default, what we could do,\xa0\n

that actually works fine. So now that we have out\xa0\n

and we implemented, let's see what happens when we\xa0\n

our gear two, and then says default method. It's\xa0\n

of our interface. Now, I believe we can actually\xa0\n

as something that's not a static method, because\xa0\n

we can actually create static methods within our\xa0\n

Like, we don't have to have an instance to\xa0\n

just follow along for a second, as I'm going to\xa0\n

int, let's return something, let's change it up.\xa0\n

a keyword. And that's fine, we'll just do math.\xa0\n

do is we're just gonna return b plus not okay. I\xa0\n

just to prove a point. So now, saying, I'm in\xa0\n

we don't create a car object. And I want to use\xa0\n

what I can do is I can do vehicle, dot, and then\xa0\n

up here, this method dot math, give it a value,\xa0\n

variable. So we'll say x equals that. And then\xa0\n

actually getting as a value. In this case,\xa0\n

there we go. So let's see, you can create a static\xa0\n

you can kind of think of these as functions.\xa0\n

I'll just do one as an example. Because this is\xa0\n

call this math, okay, then inside here, you could\xa0\n

math operations for you. Like maybe you have the\xa0\n

like Euclidean distance, I don't know a bunch of\xa0\n

interface. And then when you want to access them,\xa0\n

dot maybe like square root like sq. RT, okay. And\xa0\n

I want to call functions, but they're really\xa0\n

easily. So that is a really good example\xa0\n

Now, enums are pretty much a collection of\xa0\n

can do things with those constants. And they\xa0\n

readable. And yeah, you guys will see when we\xa0\n

create an email. Now to do that it's similar to\xa0\n

go to your package, right click, we're gonna\xa0\n

going to name mine. Actually, I'm just gonna name\xa0\n

for this example. So again, the syntax here is\xa0\n

interface or whatever, right? So in here is where\xa0\n

this is really useful, because we don't have to\xa0\n

like we can literally just type whatever value\xa0\n

it's a string. So in my case, I'm going to\xa0\n

you don't have to go all caps, we're gonna\xa0\n

are the three constants, I'm going to store in my\xa0\n

that's literally all I'm going to do right now,\xa0\n

that we can reference from level and these are\xa0\n

you want. And just keep going with commas on and\xa0\n

It just makes them more readable if you do them.\xa0\n

now I'm going to show you how we can actually use\xa0\n

works. So to use this enum, we have to create a\xa0\n

say level, and we'll say LBL equals new. Actually,\xa0\n

say a high, low and medium. So my guess we'll just\xa0\n

can see it's all showing up in different colors.\xa0\n

as a constant, we can do certain things with it,\xa0\n

value your constant is like what value is levels.\xa0\n

like so. So I say like if elvio equals equals and\xa0\n

I guess. And we'll just work our way up to high. I\xa0\n

equals, and then level dots and medium. Okay,\xa0\n

else, because if it's not lower medium, it must\xa0\n

we'll just say system dot out, dot print, ln.\xa0\n

because I want to show what this does. Okay?\xa0\n

now we're just printing level each time. And\xa0\n

happens. So you see, we get low. So when we print\xa0\n

whatever the constant is that we have. And that's\xa0\n

So we can convert these into a string. And I'll\xa0\n

say we wanted to get this because right now like,\xa0\n

we don't really know what type it is, it's just\xa0\n

get this as a string value, if we wanted to do\xa0\n

string. So if I say string, we'll say E. Yen,\xa0\n

string. And that's just going to convert this to\xa0\n

operations or whatnot with that. All right, so\xa0\n

thing that you notice is we actually get all the\xa0\n

screen. So where do system dot out? dot print ln.\xa0\n

dot values. Yes, there we are. So we go level dot\xa0\n

you're going to see when we run this, now, it\xa0\n

the values. So when we try to print that we're\xa0\n

it. So once we have these values, so I'm actually\xa0\n

then iterate through it and print them out. What\xa0\n

is the way you have to do it, let's say arr is\xa0\n

working fine. So what we're gonna do now is we'll\xa0\n

how we can loop through all the different values.\xa0\n

level E, and then we'll say, in ARR, what we'll do\xa0\n

print out E, and then we can see all the different\xa0\n

here, and you see we get high, medium, low, and\xa0\n

doing this if statement here, okay. And that's how\xa0\n

that's really cool. But you might say, Okay, well,\xa0\n

Like we just have these constants? Well, there's\xa0\n

you know, add some methods, and some instructors\xa0\n

to certain values, kind of similar to like a hash\xa0\n

way that we can do that is we need to create first\xa0\n

in this case, I'm going to say private, and I'll\xa0\n

is going to just be a private value, that's just\xa0\n

low, medium, high value of all these levels.\xa0\n

we need to create a constructor for our IEM. And\xa0\n

gonna say public level in and then none. Okay? And\xa0\n

modifiers legal modifier for short only private\xa0\n

sorry, my bad private, because we're just gonna\xa0\n

level int num, and we're just gonna say this dot\xa0\n

now what I can actually do is you see how these\xa0\n

constructor, that means we're going to define\xa0\n

for the enough. So I'm going to put brackets here\xa0\n

two as low as one. Now, what this is going to do\xa0\n

medium and low. But when we create a new constant,\xa0\n

and it's going to set this level non equal to\xa0\n

this case, 321, we could obviously have multiple,\xa0\n

multiple arguments here and we can have a ton of\xa0\n

since this value is private, we're going to need a\xa0\n

probably where we're gonna want to use it. So that\xa0\n

will change that level num and to get that level\xa0\n

I don't think I can do a public. Eye we'll see\xa0\n

we'll simply return. Guess it's gonna need to be\xa0\n

this dot, LDL num. Okay, yeah, so that does work\xa0\n

so this is just going to give us the level num. If\xa0\n

What do you call it? level num. What I'm going\xa0\n

interior it's just gonna be a void. Okay, and all\xa0\n

num, and then we're gonna put in here, int, num,\xa0\n

a way to not only get the level num, but to change\xa0\n

and see how this works. So I'm just going to get\xa0\n

right now. So right now we have our level and it's\xa0\n

this level, we can use something called get value\xa0\n

in this case, I'm going to say get level. So what\xa0\n

and in here, we'll say elvio. dot. And then what\xa0\n

So now if we print this out to the screen,\xa0\n

we're getting one. So now I'll show you this\xa0\n

x value ever get value? I'm not sure we'll see. So\xa0\n

dot value of Yes, that is exactly what it is. And\xa0\n

so in this case, we could say, low, it's gonna\xa0\n

so the issue is, I just got to put this in string,\xa0\n

value of and say I put a string in here. So like,\xa0\n

and they type in a string, right, and you want\xa0\n

actually going to get is we get low, right?\xa0\n

In the enum. Although it's not a string, it\xa0\n

value of is used for, I can't really give you\xa0\n

know any good examples of using value of but\xa0\n

I figured I would show it to you. So I guess we\xa0\n

to make sure that all that is working, say elvio\xa0\n

And then let's just grab this again, actually.\xa0\n

just simply going to print out, record elvio dot\xa0\n

changing and working fine. And there we go,\xa0\n

use itams. Pretty much they're used for when you\xa0\n

maybe you want to loop through, see what those\xa0\n

readable, right? So we have level dot low, and\xa0\n

whatever. And that's all stored within our enum\xa0\n

as you want and you'll really see the use of\xa0\n

like larger programs. Okay, so anyways, that has\xa0\n

make sure you leave a like and subscribe\xa0\n

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