All language subtitles for 003 Comparisons_en

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

Original subtitles

A bullet is only useful if you write it as a comparison.

So far, we covered every data type.

There are more, but these are the most common int long double drinka and bullion.

Now all of these types look like they serve a purpose.

But what's useful about a variable that can only store true or false?

Well, the way that you learn how to store them is pretty useless, a boolean value is only useful if

in the form of a comparison.

So in this lesson, you're going to write comparisons that return either true or false.

First thing I'm going to do is create a new class inside the section refold or create a new file named

Boolean comparison's Java and in the Boolean comparisons class, make sure it has the main method.

So what is a comparison, a comparison compares to values, then it returns true or false?

So instead of writing static, true or false values, a comparison will return true if what you write

is true and conversely, it's going to return false if what you write is false.

So, for example, this first comparison checks a five is bigger than one.

That is true.

The second comparison checks of five is less than one.

This is false.

And there are eight types of comparisons we can make greater than less than greater than or equal to

less than or equal to, equal to not equal to equal to four string values and not equal to four string.

We're going to go through all of them, but first we'll start by discussing the greater than comparison.

This comparison involves a value on the left be greater than comparison, any value on the right.

The greater then operator compares the value on the left to the value on the right.

If the value on the left is greater, the comparison returns true.

If not, the comparison is false.

You can compare any type of value like int longer double, so we'll start by making two and variables

int chemistry grade.

Is equal to 95 and into biology grade is equal to 75.

Now, your friend Harry wants to check if he did better in biology, and we're going to help him out.

We're going to check if biology grade.

Is greater than chemistry grade.

And as I run my code.

And this clearly is false.

Java checks, if Buyology great is greater than chemistry and this comparison is not true, it's false.

You can also compare decimals, so we're going to make two double variables, double sales is equal

to thirty seven point five five.

And double castes is equal to 5.5 five.

And we're going to check if the school made money, that is our sales greater than costs.

So we're going to print the comparison of checking sales being greater than costs.

We're going to run the code.

And as we do, this is a true comparison, sales are greater than costs.

You greater than comparison returns, true, because the value on the left is greater than the value

on the right.

Onto the less than comparison.

This comparison involves a value on the left, the less than operator and the value on the right now,

less then compares the value on the left to the value on the right.

If the value on the left is less, the comparison is true.

Otherwise, the comparison returns false.

So we're going to reverse the grittier then comparisons with less than.

Rerun our code.

And accordingly, the first comparison is true and the second one is false.

The first comparison is true because biology grade is indeed less than the chemistry grade.

The second comparison checks if sales are less than costs and this is false.

All right, now we're going to remove the sales and cost variable because we're not going to need them

anymore.

Onto the greater than or equal to comparison.

Once again, this involves a value on the left, the greater than or equal to the operator, any value

on the rights would be greater than or equal to comparison checks if the value on the left is greater

than or equal to the value on the rights.

If so, the comparison is true, and if not, the comparison is false.

So we're going to add a new variable English grade and we're going to set it equal to seventy five.

And we're going to check if chemistry grade.

Is greater than or equal to the English great.

Runnier code.

And this comparison returns true, that's because chemistry grade, the value on the left is greater

than Englis grade, which results in a true comparison.

Now we're going to compare it with the biology grade.

So check if biology grade is greater than or equal to English grade.

Run your code.

And once again, this is the comparison is true because English grant is equal to biology grade.

Onto the less than or equal to comparison this one checks, if I'm sure you get the pattern by now,

there is a value on the left the less than or equal to comparison, any value on the right.

And you can probably assume what this does.

So we're going to switch every operator with a less than or equal to comparison.

We run our code.

And that's interesting, the comparison returns false then true.

The first comparison checks, if chemistry rate is less than or equal to wingless grade, this is false

because chemistry grade is greater.

And the second comparison is true, because biology grade is indeed equal to English grade.

And now there's the equal comparison which returns true, if the values are equal, it returns false.

Otherwise, as always, there's a value on the left, the double equals sign any value on the rights.

So we're going to replace every operator with the equals comparison.

Rerun your code.

And we get the same results, but for different reasons, the first comparison checks if chemistry grade

is equal to English grade, which is false, and biology grade is indeed equal to the English grade.

So that returns true.

Onto the not equal comparison, the exclamation mark in Java means not this makes our operator the not

equal comparison and do not equal comparison returns.

True, if the values are not equal, it returns.

False if they are.

As you probably guessed, it involves a value on the left, the not equal comparison, any value on

the right.

So back in her coat, we're going to replace the operators with the not equal to comparison.

We're going to rerun our code.

And as you could predict, the results switch.

Now, the first comparison is true because chemistry does not equal to English grade.

And the second comparison checks at Balaji grade is not equal to English grade, and that's false.

They are equal.

The equals method checks, if string values are equal, the equals method is the same as the equal sign,

but it's four string values.

With that being said, never used the double equals sign or the not equal sine comparisons.

To compare string values, you will get inconsistent results.

The equals comparison four strings involves a string value on the left and equals method that checks

the string on the left is equal to the string on the right.

Any string value on the rights.

So we're going to make two string variables and assign them the same string value, string sentence.

We're going to set an equal to I love this course.

And we're going to make another variable that equals the same thing.

Now I'm going to compare them using the equals method.

We're going to print the result of checking if sentence equals sentence to.

We were on your code.

And this is indeed true, both strong values are equal.

And the last method we're going to look at is did not equals method, not equals method.

Checks of string values are not equal.

Remember that the exclamation mark in Java means not.

So this makes our method is not equals method.

So we're going to add an exclamation mark and we'll run honor code.

As we expect, the results should switch because the comparison checks, if the strong values are not

equal but the strong values are equal, so it's false.

Finally, I want to make sure that you don't confuse the equal signs with the single equal sign.

They are very, very different.

A single equal sign sets a variable equal to another value.

The equal sign is a comparison.

It compares to values and returns a boolean.

True or false?

In this lesson, you make comparisons that return true or false, instead of writing static, true or

false values, a comparison will return true.

If what you write is true, just like this comparison, any comparison will return false if what you

write is false.

You saw that there are eight comparison operators and in this lesson you made comparisons from all of

them.

Now you might be asking why are comparisons useful?

How can we use them?

Well, stick around as we expand into F.L. statements.

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