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
hu Hungarian Download
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,270 --> 00:00:03,000 A bullet is only useful if you write it as a comparison. 2 00:00:04,430 --> 00:00:06,290 So far, we covered every data type. 3 00:00:06,500 --> 00:00:13,010 There are more, but these are the most common int long double drinka and bullion. 4 00:00:13,940 --> 00:00:16,460 Now all of these types look like they serve a purpose. 5 00:00:16,460 --> 00:00:19,610 But what's useful about a variable that can only store true or false? 6 00:00:20,650 --> 00:00:26,320 Well, the way that you learn how to store them is pretty useless, a boolean value is only useful if 7 00:00:26,320 --> 00:00:27,850 in the form of a comparison. 8 00:00:30,770 --> 00:00:35,030 So in this lesson, you're going to write comparisons that return either true or false. 9 00:00:36,850 --> 00:00:41,350 First thing I'm going to do is create a new class inside the section refold or create a new file named 10 00:00:41,350 --> 00:00:47,710 Boolean comparison's Java and in the Boolean comparisons class, make sure it has the main method. 11 00:00:53,950 --> 00:01:01,270 So what is a comparison, a comparison compares to values, then it returns true or false? 12 00:01:02,880 --> 00:01:08,610 So instead of writing static, true or false values, a comparison will return true if what you write 13 00:01:08,610 --> 00:01:12,900 is true and conversely, it's going to return false if what you write is false. 14 00:01:13,530 --> 00:01:16,890 So, for example, this first comparison checks a five is bigger than one. 15 00:01:17,310 --> 00:01:18,150 That is true. 16 00:01:18,660 --> 00:01:21,370 The second comparison checks of five is less than one. 17 00:01:21,480 --> 00:01:22,560 This is false. 18 00:01:25,430 --> 00:01:31,520 And there are eight types of comparisons we can make greater than less than greater than or equal to 19 00:01:31,790 --> 00:01:39,500 less than or equal to, equal to not equal to equal to four string values and not equal to four string. 20 00:01:40,970 --> 00:01:45,260 We're going to go through all of them, but first we'll start by discussing the greater than comparison. 21 00:01:46,330 --> 00:01:52,300 This comparison involves a value on the left be greater than comparison, any value on the right. 22 00:01:53,410 --> 00:01:57,130 The greater then operator compares the value on the left to the value on the right. 23 00:01:57,550 --> 00:02:01,150 If the value on the left is greater, the comparison returns true. 24 00:02:01,660 --> 00:02:03,900 If not, the comparison is false. 25 00:02:08,259 --> 00:02:14,230 You can compare any type of value like int longer double, so we'll start by making two and variables 26 00:02:14,230 --> 00:02:15,670 int chemistry grade. 27 00:02:19,580 --> 00:02:24,890 Is equal to 95 and into biology grade is equal to 75. 28 00:02:30,210 --> 00:02:34,600 Now, your friend Harry wants to check if he did better in biology, and we're going to help him out. 29 00:02:35,220 --> 00:02:37,170 We're going to check if biology grade. 30 00:02:41,960 --> 00:02:43,790 Is greater than chemistry grade. 31 00:02:47,980 --> 00:02:49,720 And as I run my code. 32 00:03:02,070 --> 00:03:03,600 And this clearly is false. 33 00:03:06,110 --> 00:03:11,090 Java checks, if Buyology great is greater than chemistry and this comparison is not true, it's false. 34 00:03:15,330 --> 00:03:22,920 You can also compare decimals, so we're going to make two double variables, double sales is equal 35 00:03:22,920 --> 00:03:24,570 to thirty seven point five five. 36 00:03:25,620 --> 00:03:29,730 And double castes is equal to 5.5 five. 37 00:03:32,160 --> 00:03:36,520 And we're going to check if the school made money, that is our sales greater than costs. 38 00:03:37,240 --> 00:03:43,150 So we're going to print the comparison of checking sales being greater than costs. 39 00:03:44,810 --> 00:03:45,980 We're going to run the code. 40 00:03:57,060 --> 00:04:01,230 And as we do, this is a true comparison, sales are greater than costs. 41 00:04:03,220 --> 00:04:07,790 You greater than comparison returns, true, because the value on the left is greater than the value 42 00:04:07,790 --> 00:04:08,420 on the right. 43 00:04:12,110 --> 00:04:13,820 Onto the less than comparison. 44 00:04:15,300 --> 00:04:21,930 This comparison involves a value on the left, the less than operator and the value on the right now, 45 00:04:21,930 --> 00:04:24,910 less then compares the value on the left to the value on the right. 46 00:04:25,200 --> 00:04:28,100 If the value on the left is less, the comparison is true. 47 00:04:28,560 --> 00:04:30,810 Otherwise, the comparison returns false. 48 00:04:32,470 --> 00:04:35,740 So we're going to reverse the grittier then comparisons with less than. 49 00:04:42,510 --> 00:04:43,500 Rerun our code. 50 00:04:49,220 --> 00:04:53,510 And accordingly, the first comparison is true and the second one is false. 51 00:04:55,190 --> 00:04:59,570 The first comparison is true because biology grade is indeed less than the chemistry grade. 52 00:05:04,540 --> 00:05:08,740 The second comparison checks if sales are less than costs and this is false. 53 00:05:13,470 --> 00:05:16,980 All right, now we're going to remove the sales and cost variable because we're not going to need them 54 00:05:16,980 --> 00:05:17,340 anymore. 55 00:05:20,210 --> 00:05:22,670 Onto the greater than or equal to comparison. 56 00:05:23,800 --> 00:05:29,560 Once again, this involves a value on the left, the greater than or equal to the operator, any value 57 00:05:29,560 --> 00:05:34,960 on the rights would be greater than or equal to comparison checks if the value on the left is greater 58 00:05:34,960 --> 00:05:36,820 than or equal to the value on the rights. 59 00:05:37,300 --> 00:05:41,290 If so, the comparison is true, and if not, the comparison is false. 60 00:05:42,010 --> 00:05:47,230 So we're going to add a new variable English grade and we're going to set it equal to seventy five. 61 00:05:50,870 --> 00:05:53,060 And we're going to check if chemistry grade. 62 00:05:55,730 --> 00:05:58,280 Is greater than or equal to the English great. 63 00:06:02,340 --> 00:06:03,240 Runnier code. 64 00:06:07,270 --> 00:06:13,210 And this comparison returns true, that's because chemistry grade, the value on the left is greater 65 00:06:13,210 --> 00:06:16,710 than Englis grade, which results in a true comparison. 66 00:06:18,350 --> 00:06:20,510 Now we're going to compare it with the biology grade. 67 00:06:26,320 --> 00:06:29,800 So check if biology grade is greater than or equal to English grade. 68 00:06:34,700 --> 00:06:35,630 Run your code. 69 00:06:38,910 --> 00:06:44,880 And once again, this is the comparison is true because English grant is equal to biology grade. 70 00:06:47,870 --> 00:06:53,920 Onto the less than or equal to comparison this one checks, if I'm sure you get the pattern by now, 71 00:06:54,410 --> 00:06:58,930 there is a value on the left the less than or equal to comparison, any value on the right. 72 00:06:59,360 --> 00:07:01,210 And you can probably assume what this does. 73 00:07:01,940 --> 00:07:05,660 So we're going to switch every operator with a less than or equal to comparison. 74 00:07:10,320 --> 00:07:11,430 We run our code. 75 00:07:16,480 --> 00:07:20,050 And that's interesting, the comparison returns false then true. 76 00:07:21,420 --> 00:07:26,550 The first comparison checks, if chemistry rate is less than or equal to wingless grade, this is false 77 00:07:26,550 --> 00:07:28,200 because chemistry grade is greater. 78 00:07:30,000 --> 00:07:34,770 And the second comparison is true, because biology grade is indeed equal to English grade. 79 00:07:39,460 --> 00:07:44,590 And now there's the equal comparison which returns true, if the values are equal, it returns false. 80 00:07:44,590 --> 00:07:50,440 Otherwise, as always, there's a value on the left, the double equals sign any value on the rights. 81 00:07:53,370 --> 00:07:56,400 So we're going to replace every operator with the equals comparison. 82 00:07:59,310 --> 00:08:00,270 Rerun your code. 83 00:08:05,610 --> 00:08:10,980 And we get the same results, but for different reasons, the first comparison checks if chemistry grade 84 00:08:10,980 --> 00:08:16,830 is equal to English grade, which is false, and biology grade is indeed equal to the English grade. 85 00:08:16,830 --> 00:08:18,120 So that returns true. 86 00:08:21,170 --> 00:08:27,890 Onto the not equal comparison, the exclamation mark in Java means not this makes our operator the not 87 00:08:27,890 --> 00:08:31,310 equal comparison and do not equal comparison returns. 88 00:08:31,310 --> 00:08:33,740 True, if the values are not equal, it returns. 89 00:08:33,740 --> 00:08:34,640 False if they are. 90 00:08:35,630 --> 00:08:40,650 As you probably guessed, it involves a value on the left, the not equal comparison, any value on 91 00:08:40,650 --> 00:08:41,070 the right. 92 00:08:44,620 --> 00:08:48,670 So back in her coat, we're going to replace the operators with the not equal to comparison. 93 00:08:51,280 --> 00:08:52,540 We're going to rerun our code. 94 00:08:55,980 --> 00:08:58,650 And as you could predict, the results switch. 95 00:09:01,240 --> 00:09:05,050 Now, the first comparison is true because chemistry does not equal to English grade. 96 00:09:07,830 --> 00:09:12,450 And the second comparison checks at Balaji grade is not equal to English grade, and that's false. 97 00:09:12,630 --> 00:09:13,470 They are equal. 98 00:09:15,410 --> 00:09:21,170 The equals method checks, if string values are equal, the equals method is the same as the equal sign, 99 00:09:21,170 --> 00:09:22,500 but it's four string values. 100 00:09:23,360 --> 00:09:27,950 With that being said, never used the double equals sign or the not equal sine comparisons. 101 00:09:27,950 --> 00:09:31,430 To compare string values, you will get inconsistent results. 102 00:09:32,040 --> 00:09:37,730 The equals comparison four strings involves a string value on the left and equals method that checks 103 00:09:37,820 --> 00:09:40,070 the string on the left is equal to the string on the right. 104 00:09:40,070 --> 00:09:41,720 Any string value on the rights. 105 00:09:43,040 --> 00:09:47,930 So we're going to make two string variables and assign them the same string value, string sentence. 106 00:09:48,290 --> 00:09:50,810 We're going to set an equal to I love this course. 107 00:09:56,460 --> 00:09:59,270 And we're going to make another variable that equals the same thing. 108 00:10:09,230 --> 00:10:11,570 Now I'm going to compare them using the equals method. 109 00:10:12,410 --> 00:10:17,660 We're going to print the result of checking if sentence equals sentence to. 110 00:10:26,530 --> 00:10:27,520 We were on your code. 111 00:10:36,400 --> 00:10:40,150 And this is indeed true, both strong values are equal. 112 00:10:42,470 --> 00:10:46,700 And the last method we're going to look at is did not equals method, not equals method. 113 00:10:46,700 --> 00:10:48,590 Checks of string values are not equal. 114 00:10:48,860 --> 00:10:51,380 Remember that the exclamation mark in Java means not. 115 00:10:51,590 --> 00:10:53,990 So this makes our method is not equals method. 116 00:10:54,850 --> 00:10:57,880 So we're going to add an exclamation mark and we'll run honor code. 117 00:11:03,580 --> 00:11:08,860 As we expect, the results should switch because the comparison checks, if the strong values are not 118 00:11:08,860 --> 00:11:11,950 equal but the strong values are equal, so it's false. 119 00:11:13,630 --> 00:11:17,780 Finally, I want to make sure that you don't confuse the equal signs with the single equal sign. 120 00:11:18,010 --> 00:11:19,720 They are very, very different. 121 00:11:20,300 --> 00:11:23,470 A single equal sign sets a variable equal to another value. 122 00:11:24,250 --> 00:11:26,100 The equal sign is a comparison. 123 00:11:26,140 --> 00:11:28,630 It compares to values and returns a boolean. 124 00:11:28,630 --> 00:11:29,800 True or false? 125 00:11:32,740 --> 00:11:37,720 In this lesson, you make comparisons that return true or false, instead of writing static, true or 126 00:11:37,720 --> 00:11:40,150 false values, a comparison will return true. 127 00:11:40,150 --> 00:11:45,910 If what you write is true, just like this comparison, any comparison will return false if what you 128 00:11:45,910 --> 00:11:46,870 write is false. 129 00:11:47,680 --> 00:11:52,390 You saw that there are eight comparison operators and in this lesson you made comparisons from all of 130 00:11:52,390 --> 00:11:52,610 them. 131 00:11:53,410 --> 00:11:55,980 Now you might be asking why are comparisons useful? 132 00:11:55,990 --> 00:11:57,050 How can we use them? 133 00:11:57,490 --> 00:12:01,240 Well, stick around as we expand into F.L. statements. 13518

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