1 00:00:02,760 --> 00:00:09,480 And this lecture, I'm going to talk about operators, so why we need operators, because we need to 2 00:00:09,480 --> 00:00:17,510 change the value of the variables somehow and the signs or operators help us to do the job. 3 00:00:18,120 --> 00:00:23,020 Some of them are well known from math and others might be new for you. 4 00:00:23,580 --> 00:00:26,640 There are operators that are connected to numbers. 5 00:00:26,670 --> 00:00:28,750 Others are helping in comparison. 6 00:00:29,010 --> 00:00:36,470 So what operators are by definition, they are used to perform operations on variables and values. 7 00:00:36,840 --> 00:00:39,840 I think it will be more clear if I introduce them. 8 00:00:40,680 --> 00:00:43,430 This lecture is divided into six parts. 9 00:00:43,920 --> 00:00:47,020 The first one will be assignment operators. 10 00:00:47,460 --> 00:00:53,610 Second, we will look into arithmetic operators, then on the operators. 11 00:00:54,150 --> 00:00:57,690 After that, equality and relational operators. 12 00:00:58,140 --> 00:01:03,810 The next problem will be the ternary operator and last the two logical operators. 13 00:01:04,200 --> 00:01:09,510 After we will finish with these, there will be a coding lecture to that started. 14 00:01:09,750 --> 00:01:13,980 So you have been the first assigned operator, the equal sign. 15 00:01:14,730 --> 00:01:16,010 Nothing special here. 16 00:01:16,520 --> 00:01:23,340 Here are many other assignment operators, but to understand them, we must go through other operators 17 00:01:23,340 --> 00:01:23,880 first. 18 00:01:24,090 --> 00:01:26,620 We will get back here at the end of the lecture. 19 00:01:27,420 --> 00:01:32,850 So moving on to arithmetic operators, the first one, the plus sign for addition. 20 00:01:33,180 --> 00:01:35,010 It's also used for strengths. 21 00:01:35,280 --> 00:01:38,070 Subtraction is also a simple one. 22 00:01:38,370 --> 00:01:41,610 Multiplication not too complicated either. 23 00:01:41,970 --> 00:01:44,550 OK, the next one is a bit trickier. 24 00:01:45,360 --> 00:01:49,560 Division divides the number and returns the whole part. 25 00:01:49,800 --> 00:01:52,320 We will look into this in the coding part. 26 00:01:53,910 --> 00:01:55,650 Moving on to the next operator. 27 00:01:55,950 --> 00:01:56,960 The reminder. 28 00:01:57,300 --> 00:02:04,710 So in case of price variable, we divide five with free and what remained is two. 29 00:02:05,070 --> 00:02:08,250 So that what reminder operator returns for us. 30 00:02:08,400 --> 00:02:11,220 We will cover all of these with examples. 31 00:02:12,030 --> 00:02:16,020 These operators are commonly used, but there is nothing unusual here. 32 00:02:16,830 --> 00:02:19,140 Moving on to unary operators. 33 00:02:19,260 --> 00:02:26,430 Honourary operators have the name unary because they are not connected to another value or variable. 34 00:02:26,670 --> 00:02:34,230 They can be used for one variable we can use plus sign phone numbers, but it won't make a negative 35 00:02:34,230 --> 00:02:35,550 value to positive. 36 00:02:36,210 --> 00:02:46,110 But minus sign will do double plus sign increases the value by one and double minus will decrease it 37 00:02:46,110 --> 00:02:46,800 by one. 38 00:02:47,790 --> 00:02:52,590 Both can be used before and after the variable or value. 39 00:02:53,310 --> 00:02:58,260 And the last one in this group is the exclamation mark or invert. 40 00:02:58,770 --> 00:03:06,810 It can be used for booleans to change the true to false and false to true in the case of the example 41 00:03:06,810 --> 00:03:10,710 here is damaged will have a false value. 42 00:03:11,990 --> 00:03:19,580 The next group is used to compare variables and values stored in those variables, the result of the 43 00:03:19,580 --> 00:03:21,910 comparison will be a boolean. 44 00:03:22,730 --> 00:03:27,640 So first double equals use to compare to values. 45 00:03:27,650 --> 00:03:30,650 Five equals five will return to. 46 00:03:30,890 --> 00:03:33,420 The second one is not equals. 47 00:03:33,590 --> 00:03:36,340 So five not equals five. 48 00:03:36,350 --> 00:03:45,350 So it will return false because five equals to five third and fourth greater than and less certain. 49 00:03:45,590 --> 00:03:48,530 I think I don't have to tell you how they operate. 50 00:03:48,710 --> 00:03:54,850 The next two are greater than or equals and less than or equals. 51 00:03:55,550 --> 00:03:57,950 These are also well known from math. 52 00:03:59,690 --> 00:04:05,360 The last one here is a bonus and it is used for data type check. 53 00:04:05,600 --> 00:04:12,410 You can check whether a variable data type is string or any other object. 54 00:04:13,130 --> 00:04:14,870 We will get back to this later. 55 00:04:15,530 --> 00:04:19,280 Ternary Operator Group is a one operator group. 56 00:04:19,670 --> 00:04:25,580 It is used in control flows to run different code based on expression values. 57 00:04:25,970 --> 00:04:36,380 So variable name equals expression, questionmark expression one, common expression two and a semicolon. 58 00:04:36,800 --> 00:04:44,300 So if the expression is true expression, one will be assigned to the variable. 59 00:04:45,020 --> 00:04:55,910 If expression is false expression two will be assigned in case of a car damaged text while you will 60 00:04:55,910 --> 00:05:00,260 be this car is damaged if the is damaged is true. 61 00:05:01,130 --> 00:05:03,560 But if it's damaged is false. 62 00:05:04,190 --> 00:05:07,430 Damaged text will be this car isn't damaged. 63 00:05:08,590 --> 00:05:17,890 Let's move on to the next one, so logical operators have two elements, the first one is or operator, 64 00:05:18,490 --> 00:05:28,300 two vertical lines if we have to boolean expressions and at least one of them is true, the other operator 65 00:05:28,600 --> 00:05:33,100 will return it through the other operator. 66 00:05:33,100 --> 00:05:42,910 And this group is and operator, it will be true if both boolean expressions are true, so false and 67 00:05:42,910 --> 00:05:45,820 true, we will return a false. 68 00:05:47,680 --> 00:05:52,920 On the other hand, true and true would return true. 69 00:05:53,800 --> 00:05:57,840 I think it will be much easier to understand in the coding part. 70 00:05:58,660 --> 00:06:05,530 So moving back to assignment operators now, you have introduced to other operators that will be needed 71 00:06:05,530 --> 00:06:06,400 for this part. 72 00:06:06,790 --> 00:06:17,680 We will use enterprise equals five as a base for all the examples first from the new ones ad and equals 73 00:06:18,370 --> 00:06:26,500 it takes the price variable, adds five to it and assigns 10 to price variable. 74 00:06:26,890 --> 00:06:29,410 This operator can replace the following. 75 00:06:29,980 --> 00:06:35,320 It makes it easier because you don't have to type in price two times. 76 00:06:35,930 --> 00:06:38,830 Next is subtract and equals. 77 00:06:39,340 --> 00:06:49,480 It takes price with value five and subtract five and assigns zero to price variable based on the one. 78 00:06:49,480 --> 00:06:52,270 Before this it can replace the following. 79 00:06:52,270 --> 00:07:04,090 So price equals price minus five, then multiply and equals five is multiplied by three and price will 80 00:07:04,090 --> 00:07:08,950 be fifteen in that case and it can replace the following. 81 00:07:12,400 --> 00:07:20,470 Divide and equals does the same way, and at the end, the value of price will be won and the line it 82 00:07:20,470 --> 00:07:29,530 can replace also on the right and the last one as a reminder and equals the value of price will be to. 83 00:07:33,050 --> 00:07:39,590 One last group I didn't even mention at the beginning is bitwise and big shift operators, and there 84 00:07:39,590 --> 00:07:42,140 is a good reason why I didn't mention them. 85 00:07:42,410 --> 00:07:44,020 These are not commonly used. 86 00:07:44,030 --> 00:07:51,680 Maybe I can say never the reason why I still mention them, because the way they wrote is close to other 87 00:07:51,680 --> 00:07:52,580 operators. 88 00:07:52,790 --> 00:08:01,760 And if you miss, for example, a vertical line from your operator, you will get bitwise or which won't 89 00:08:01,760 --> 00:08:03,800 give you the same result at all. 90 00:08:04,280 --> 00:08:13,280 If you miss an unsigned from double and operator, you will get bitwise and then right shift and left 91 00:08:13,280 --> 00:08:19,940 shift that are close to greater than and less certain and unassigned right shift. 92 00:08:20,690 --> 00:08:28,070 The last two are bitwise complement and bitwise X or as I said, you don't have to know these. 93 00:08:28,070 --> 00:08:31,180 Just keep in mind that Java has such things as well. 94 00:08:32,300 --> 00:08:33,170 So that's it. 95 00:08:33,440 --> 00:08:35,180 Let's move on to the coding part.