1 00:00:01,090 --> 00:00:07,100 Let us not proceed and check out one more concept in case of Cartan such as Date classes and also in 2 00:00:07,100 --> 00:00:15,120 the previous video we learn that Bideford Every class has a superclass of any and this class of any 3 00:00:15,330 --> 00:00:22,310 provides the functions are emitters such as equals method hash for the method and also to string method. 4 00:00:22,440 --> 00:00:27,840 So all these methods are by default present in every class that we define inside the Cartland file. 5 00:00:28,050 --> 00:00:34,290 And now proceeding forward when we use the data classes the Cartland simply provides a copy method for 6 00:00:34,290 --> 00:00:35,690 us that we will check out. 7 00:00:35,700 --> 00:00:37,180 Inside the demo video. 8 00:00:37,620 --> 00:00:44,250 And now they're Dudack classes simply provides these mentioned metters implementation so we can make 9 00:00:44,250 --> 00:00:47,700 effective use of these methods inside their classes. 10 00:00:47,700 --> 00:00:50,280 Navar does this data classes dance for. 11 00:00:50,370 --> 00:00:51,140 Check it out. 12 00:00:51,330 --> 00:00:55,050 So here inside the 80 I have a class of user. 13 00:00:55,240 --> 00:00:58,620 Now as a field variable are the property of the user. 14 00:00:58,620 --> 00:01:01,490 I will simply define the name and ID. 15 00:01:01,500 --> 00:01:06,750 So here I have simply defined the property name and also ID on the student or the user. 16 00:01:06,810 --> 00:01:07,670 Right. 17 00:01:07,800 --> 00:01:12,680 And now inside the main function I will simply define two objects of the user. 18 00:01:12,900 --> 00:01:15,510 So here I have used an end user two. 19 00:01:15,660 --> 00:01:21,130 If you are just here I have a user name as Sam and here Sam as well. 20 00:01:21,170 --> 00:01:23,410 I and then here as well. 21 00:01:23,490 --> 00:01:27,840 So both these user and user 2 has the same name and same ID. 22 00:01:27,840 --> 00:01:39,020 Now if I compare let's say User 1 equal to equal to user 2 then simply print out equal is not equal. 23 00:01:39,210 --> 00:01:41,390 So let us note in the code. 24 00:01:41,400 --> 00:01:44,080 So in the output we have not equal. 25 00:01:44,100 --> 00:01:47,180 Now you must be wondering that these two values are the same Sam. 26 00:01:47,280 --> 00:01:51,210 Dan Santon so why not use that have an end user to equal. 27 00:01:51,390 --> 00:01:54,690 Just because here we are simply creating two objects. 28 00:01:54,840 --> 00:01:57,320 And these are actually two differences. 29 00:01:57,360 --> 00:02:01,470 So these are two different objects created inside the heap memory. 30 00:02:01,770 --> 00:02:05,060 So here we are actually comparing the object reference. 31 00:02:05,130 --> 00:02:07,520 So both are in this case are different. 32 00:02:07,560 --> 00:02:08,080 Right. 33 00:02:08,280 --> 00:02:12,000 So that is why we get not equal in case of Cartland. 34 00:02:12,030 --> 00:02:17,580 Now in case of Djala as well if you are from a Java background then you must be doing what I'm talking 35 00:02:17,580 --> 00:02:18,320 about. 36 00:02:18,390 --> 00:02:20,420 Then we create user and user. 37 00:02:20,550 --> 00:02:22,830 It simply creates two different objects. 38 00:02:22,830 --> 00:02:24,420 But with the same value. 39 00:02:24,480 --> 00:02:32,220 And now if I change this class with the help of a keyword of data let's say a data base class user and 40 00:02:32,220 --> 00:02:34,210 now like I said in the code. 41 00:02:34,380 --> 00:02:35,510 And now in the output. 42 00:02:35,540 --> 00:02:37,820 So will we have equal in the output. 43 00:02:37,860 --> 00:02:44,530 No this is simply because the purpose of the class is just to deal with data not the objects. 44 00:02:44,550 --> 00:02:52,170 So here when we compare the use of an end user to it simply compares the values such as Sam then Sam 45 00:02:52,170 --> 00:02:55,830 then search simply prints out equal in the output console. 46 00:02:55,830 --> 00:02:58,430 So this is the beauty of using data. 47 00:02:58,560 --> 00:03:04,290 Then you want to only deal with their data or you want to compare their data then simply use their data 48 00:03:04,320 --> 00:03:05,920 keyword in case of class. 49 00:03:05,940 --> 00:03:06,510 Right. 50 00:03:06,790 --> 00:03:19,170 And now suppose if I print here let's see lane use one dog string right like this or even if we don't 51 00:03:19,170 --> 00:03:22,160 use to string then also so let's see what happens. 52 00:03:22,290 --> 00:03:25,360 Now here let us first remove their data keyword. 53 00:03:25,590 --> 00:03:27,520 Let us note in the code. 54 00:03:27,680 --> 00:03:34,850 So in the output we have some address of the object of user Gandara Mike or Lindora do use some address 55 00:03:34,850 --> 00:03:38,510 location of this user object right now. 56 00:03:38,630 --> 00:03:44,360 If I use the data keyword here and now let us run the code. 57 00:03:44,440 --> 00:03:51,320 So this time this trendline user is simply printing or the value of this user that is name equal to 58 00:03:51,370 --> 00:03:53,340 sign an ID equal to 10. 59 00:03:53,350 --> 00:03:57,950 So here implicitly we are actually calling to string method. 60 00:03:58,000 --> 00:03:59,330 Let us run the court again. 61 00:04:00,860 --> 00:04:03,850 So here we go the same output is actually present here. 62 00:04:03,980 --> 00:04:10,400 So by default this data class actually provides their default implementation of their two string method 63 00:04:10,700 --> 00:04:16,760 which is actually the part of the any class which is the superclass of any classes in case of Cartland. 64 00:04:16,820 --> 00:04:17,950 Right. 65 00:04:18,140 --> 00:04:25,580 So that is why we are getting the value and now presenting forward here down the side leg we show you 66 00:04:25,580 --> 00:04:26,700 the copy method. 67 00:04:26,900 --> 00:04:33,760 So that let's say new user equal to use it when dart copy Metford. 68 00:04:33,770 --> 00:04:41,310 Now here I can simply use new user equal to use the rendered copy elaters printed and let us note in 69 00:04:41,320 --> 00:04:46,160 the chord so in the output we have the value of the new user. 70 00:04:46,190 --> 00:04:49,380 Again namea quite the same and equal to 10. 71 00:04:49,380 --> 00:04:56,520 So we are perfectly able to copy from their data from one user and then putting it inside the new reference 72 00:04:56,520 --> 00:04:57,710 of new user. 73 00:04:57,720 --> 00:04:58,240 Right. 74 00:04:58,410 --> 00:05:03,710 And now suppose I'm on the override such as the value of Sam let's say it to Peter. 75 00:05:03,840 --> 00:05:06,980 So I would simply use name equal to. 76 00:05:07,020 --> 00:05:07,890 Let's see. 77 00:05:08,070 --> 00:05:12,720 Peter and now there are just called. 78 00:05:12,850 --> 00:05:15,860 So in the output we have the name as Peter. 79 00:05:15,900 --> 00:05:18,990 But the idea is still remaining C that is then. 80 00:05:19,230 --> 00:05:24,650 So in this way you can simply change the value of the variable such as name while copying the use that 81 00:05:24,660 --> 00:05:26,090 object to an adder. 82 00:05:26,160 --> 00:05:26,670 Right. 83 00:05:26,880 --> 00:05:32,930 And I suppose if you want you can also use let's say 80 equal to 25 something like that. 84 00:05:32,940 --> 00:05:33,390 Right. 85 00:05:33,510 --> 00:05:35,490 So you can simply change the values. 86 00:05:35,550 --> 00:05:40,470 And if you want to change the sequence then you can simply change it by simply using the equal to let's 87 00:05:40,470 --> 00:05:41,370 say grade 5. 88 00:05:41,520 --> 00:05:42,840 Let us note in the code. 89 00:05:42,930 --> 00:05:48,040 So here this time the ighly will be changed but the name will remain Samm like this. 90 00:05:48,090 --> 00:05:51,400 The name is Sam but the ID is now changed to 25. 91 00:05:51,450 --> 00:05:54,980 Now notice here that we are using the named leaders. 92 00:05:55,170 --> 00:05:57,180 Now the concept of named barometers. 93 00:05:57,210 --> 00:06:02,650 We already saw in the previous Marty when we talked about functions in case of Coughlin. 94 00:06:02,670 --> 00:06:07,530 So if you are simply defining the name of the speedometer as ighly equal to the value. 95 00:06:07,800 --> 00:06:09,430 So no matter what is a sequence. 96 00:06:09,450 --> 00:06:17,040 If you defined the name bit weaker than this value will only fall here in spite of the first bit weaker 97 00:06:17,190 --> 00:06:18,080 remains the name. 98 00:06:18,100 --> 00:06:24,520 And here the first parameter is ID so the ID will simply match with this ID and this ID value will be 99 00:06:24,520 --> 00:06:26,540 overridden from end to 25. 100 00:06:26,560 --> 00:06:27,190 Like this. 101 00:06:27,190 --> 00:06:27,750 Right. 102 00:06:28,060 --> 00:06:33,710 And now at the end of this video let me show you something is does not move this that keyword. 103 00:06:33,850 --> 00:06:41,700 So here it shows an error that in case of day that is that primary constructor should only contain the 104 00:06:41,710 --> 00:06:43,110 property be it on meters. 105 00:06:43,120 --> 00:06:46,060 So it says either that or either. 106 00:06:46,090 --> 00:06:48,260 Well it cannot contain the. 107 00:06:48,270 --> 00:06:48,760 I. 108 00:06:48,840 --> 00:06:49,120 Right. 109 00:06:49,120 --> 00:06:55,600 So always remember in case of that last is the primary constructor it should only contain the property 110 00:06:55,750 --> 00:06:59,850 variables such as that are valid. 111 00:06:59,860 --> 00:07:03,140 So this was all about this video of the glasses. 112 00:07:03,250 --> 00:07:05,230 So thanks for watching and have a good day.