1 00:00:00,480 --> 00:00:03,720 We are going to do some coding with object references. 2 00:00:04,200 --> 00:00:06,340 Let's create a new class for this. 3 00:00:06,420 --> 00:00:06,930 Right. 4 00:00:06,930 --> 00:00:14,640 Click on the my first Java app, new Java class, let's call it object references app. 5 00:00:21,230 --> 00:00:21,800 Enter. 6 00:00:22,640 --> 00:00:23,940 At some space here. 7 00:00:25,820 --> 00:00:29,840 Now let's go back to my first Java app, double click on the file. 8 00:00:31,440 --> 00:00:34,990 And copy this line, the main method. 9 00:00:35,640 --> 00:00:40,490 Go back to object references app and paste it here. 10 00:00:41,920 --> 00:00:49,990 Hit enter after the colobus and intelligibly will add the pair of it and some space here, too. 11 00:00:50,560 --> 00:00:56,500 Let's create one of each built in object references, data type that has a primitive version. 12 00:00:56,950 --> 00:01:14,140 So bored with uppercase number of seats equals five and a semicolon, short horsepower. 13 00:01:16,460 --> 00:01:23,540 Equals free to integer instead of end. 14 00:01:26,110 --> 00:01:43,810 Price equals forty nine point nine and a semicolon long registration number equals and a random number 15 00:01:44,680 --> 00:01:48,830 and an L to the end of those numbers and they semicon. 16 00:01:50,050 --> 00:01:50,710 All right. 17 00:01:50,720 --> 00:01:55,090 So the next one is a float fuel. 18 00:01:57,520 --> 00:02:14,110 Consumption urban equals fifteen point five and a half and a semicolon now created double double fuel 19 00:02:15,760 --> 00:02:20,740 consumption, precise 20 00:02:23,500 --> 00:02:32,430 average equals fifteen point random numbers and a semicolon. 21 00:02:32,920 --> 00:02:34,270 Two more primitives left. 22 00:02:34,270 --> 00:02:47,890 So Boolean is damaged equals true and correct instead of char. 23 00:02:50,410 --> 00:02:53,770 Energy efficiency 24 00:02:55,690 --> 00:03:04,270 category equals simple quotes G and a semicolon. 25 00:03:08,430 --> 00:03:09,050 There we go. 26 00:03:10,930 --> 00:03:24,460 We added the primitives, let's add a string here, so string car type or car model equals double quartz 27 00:03:25,390 --> 00:03:26,050 dodge 28 00:03:28,570 --> 00:03:36,930 challenger Esbati Free Nanita and a semicolon. 29 00:03:37,330 --> 00:03:41,080 As I said, we can create an object with the new keyword. 30 00:03:41,390 --> 00:03:44,300 Let's create another variable with the same value. 31 00:03:44,350 --> 00:03:46,840 So string. 32 00:03:48,230 --> 00:04:00,650 Car type model with new keywords equals new. 33 00:04:01,620 --> 00:04:07,110 String double quotes Dodge. 34 00:04:11,500 --> 00:04:16,510 Challenger, SRT three ninety two. 35 00:04:17,350 --> 00:04:23,140 All right, and a semicolon to the end of the line, both give us the same result. 36 00:04:23,140 --> 00:04:25,030 But the one about is simple here. 37 00:04:25,540 --> 00:04:34,510 And as you can see, grade the new string version, hooved your mouse over the new string text to see 38 00:04:34,510 --> 00:04:35,440 what's the problem. 39 00:04:35,980 --> 00:04:41,920 The new string is redundant and intelligent, offers us a option. 40 00:04:42,310 --> 00:04:45,910 So to replace the argument, let's click on it. 41 00:04:46,600 --> 00:04:51,010 So it made the line the same as the one before this. 42 00:04:51,790 --> 00:04:57,490 Actually, you don't have to use the second version in case of string, but later we will use the new 43 00:04:57,490 --> 00:04:58,630 keyword a lot. 44 00:04:59,290 --> 00:05:04,180 For now, reverse the change with controversy or command the. 45 00:05:06,100 --> 00:05:17,440 And let's leave it as it is, so now let's print out some of the values so as O u t or system that our 46 00:05:17,440 --> 00:05:20,080 DOT printed on its enter. 47 00:05:21,050 --> 00:05:21,980 Double quotes. 48 00:05:23,960 --> 00:05:30,860 Number of seats, column space. 49 00:05:32,020 --> 00:05:36,610 Plus, number of seats double the line. 50 00:05:37,610 --> 00:05:38,540 Horsepower. 51 00:05:44,730 --> 00:05:50,490 And replace the number of seats, variable name, horsepower loss. 52 00:05:52,130 --> 00:05:52,940 HP. 53 00:05:54,450 --> 00:06:05,010 Double the line again, we bring the price here, it's a price and a euro mark here 54 00:06:09,900 --> 00:06:15,270 price and remove the rest top of the line. 55 00:06:18,280 --> 00:06:21,520 Registration number. 56 00:06:29,340 --> 00:06:31,030 Top of the line again. 57 00:06:35,480 --> 00:06:36,190 Fuel. 58 00:06:37,590 --> 00:06:41,370 Sorry, urban fuel. 59 00:06:44,940 --> 00:06:46,380 Consumption. 60 00:06:55,030 --> 00:06:58,180 Plus double cotes 61 00:07:00,460 --> 00:07:04,600 liter per 100 km. 62 00:07:07,310 --> 00:07:08,800 Top of the line again. 63 00:07:10,430 --> 00:07:22,460 So it's going to be the precise, precise, average fuel consumption replace the variable name. 64 00:07:25,020 --> 00:07:30,060 And we have four left to go, so. 65 00:07:32,520 --> 00:07:33,360 The Boolean. 66 00:07:36,780 --> 00:07:47,940 The car is damaged, plus is damaged and removed the rest. 67 00:07:51,630 --> 00:07:56,040 Top of the line energy efficiency category. 68 00:08:13,170 --> 00:08:16,890 And the last to the strings, top of the line. 69 00:08:21,020 --> 00:08:32,640 Bar model, plus car type and double the line and card type. 70 00:08:33,430 --> 00:08:35,980 With the new key word. 71 00:08:38,620 --> 00:08:44,310 Well, if you keep your word, so that's it, let's run the code. 72 00:08:50,320 --> 00:08:56,470 So as you can see, everything worked fine, there is no difference between the primitive version and 73 00:08:56,860 --> 00:08:58,850 the object references version. 74 00:08:58,990 --> 00:09:02,310 So the question is why we have the objects here. 75 00:09:02,590 --> 00:09:10,210 For example, we can have cases when we need the float value of the price, which is a whole number 76 00:09:10,360 --> 00:09:14,710 to show that there is no decimal part of that value. 77 00:09:15,010 --> 00:09:22,060 And on the other hand, we don't want to store a flawed version and an integer version of the price 78 00:09:22,270 --> 00:09:26,890 to show that we have to go to the price variable name. 79 00:09:28,500 --> 00:09:36,420 Here, type in a dot at the end of the price variable name like this, and you can see the available 80 00:09:36,420 --> 00:09:43,230 functions here, the function names are on the left and the return data types are on the right. 81 00:09:43,920 --> 00:09:50,840 So we are going to need a function that returns a floating point number so we can go with the float 82 00:09:50,850 --> 00:09:53,430 value or the double value. 83 00:09:53,670 --> 00:09:56,550 Actually, both of them can do the job. 84 00:09:56,640 --> 00:09:58,740 I'm going to go with the float value. 85 00:09:59,160 --> 00:10:00,330 So hit enter. 86 00:10:00,670 --> 00:10:01,860 Let's run the code again. 87 00:10:10,160 --> 00:10:13,930 And as you can see, the price appears as a float number. 88 00:10:14,180 --> 00:10:15,900 Now let's reverse it. 89 00:10:15,950 --> 00:10:20,600 We want to print out the integer version of the precise fuel consumption. 90 00:10:20,930 --> 00:10:24,380 So go to the end of the fuel consumption variable name. 91 00:10:27,440 --> 00:10:35,360 I dot and choose one of the functions that returns a whole number, so bye to value short value, integer 92 00:10:35,360 --> 00:10:37,540 value, even long value, you can do it. 93 00:10:38,000 --> 00:10:39,680 I will go with the value. 94 00:10:42,360 --> 00:10:43,320 Run the code again. 95 00:10:48,890 --> 00:10:56,030 As you can see, Java chopped off the decimal part and didn't use any rounding, and we got the whole 96 00:10:56,030 --> 00:10:57,930 number before we finish it. 97 00:10:57,950 --> 00:11:00,950 I would like to show you some string functions. 98 00:11:03,130 --> 00:11:06,070 Double the Kameda line and let's use. 99 00:11:07,410 --> 00:11:17,810 Talked to uppercase here and changed the text as well with Case. 100 00:11:19,170 --> 00:11:20,580 Top of the line again. 101 00:11:21,920 --> 00:11:23,030 Now use. 102 00:11:25,010 --> 00:11:27,920 To not work case. 103 00:11:29,680 --> 00:11:38,230 With the lower case, and we can also check whether the two streams are equal or not, so double the 104 00:11:38,230 --> 00:11:39,100 last line. 105 00:11:41,170 --> 00:11:45,550 And at the end of the car type with new key words, place a dot. 106 00:11:46,570 --> 00:11:48,430 And equals. 107 00:11:50,350 --> 00:11:53,530 And variable name card type. 108 00:11:55,630 --> 00:12:02,950 And changed the tax to car type variable. 109 00:12:06,460 --> 00:12:15,240 Equals two car type with new key words. 110 00:12:17,380 --> 00:12:19,450 And that's it, run the code again. 111 00:12:27,190 --> 00:12:35,230 And as you can see, the string appears with an uppercase done with a lower case, and the last line 112 00:12:35,230 --> 00:12:39,480 is Khatar Frebel equals toccata with new keywords is true. 113 00:12:39,820 --> 00:12:42,930 So that's all I wanted to say about object references. 114 00:12:42,940 --> 00:12:47,140 For now, I hope it was clear and useful saying the next lecture.