1 00:00:00,360 --> 00:00:01,110 Welcome back. 2 00:00:01,110 --> 00:00:06,420 In the last week, we created our first variables and we used immutable variables. 3 00:00:07,020 --> 00:00:13,140 And we also saw what an immutable variable is, how immutable variable. 4 00:00:13,530 --> 00:00:16,950 Now what I'm using here is a comment. 5 00:00:17,130 --> 00:00:18,540 So this here is a comment. 6 00:00:18,820 --> 00:00:26,190 This is code that will not be considered by the compiler, so it will not have any influence onto our 7 00:00:26,370 --> 00:00:28,110 application or our program. 8 00:00:28,440 --> 00:00:34,200 It's just a comment that helps me to understand what my code does, and it also helps other developers 9 00:00:34,200 --> 00:00:35,820 to understand what code does. 10 00:00:36,180 --> 00:00:42,480 And they are really great to not only understand what code does, but they are also great in order to 11 00:00:42,660 --> 00:00:44,080 know what would you need to do. 12 00:00:44,100 --> 00:00:50,490 So, for example, if you had to do, then you know, OK, at this point, I will need to add a functionality, 13 00:00:50,490 --> 00:00:53,700 add new functionality, for example. 14 00:00:54,150 --> 00:01:00,180 And this is great, because then you can go to your To-Do window here at the bottom and you can very 15 00:01:00,180 --> 00:01:02,200 quickly find this. 16 00:01:02,220 --> 00:01:04,800 So let's say I go to a different document. 17 00:01:07,890 --> 00:01:09,540 And I go to my. 18 00:01:11,160 --> 00:01:15,840 Main activity and now in my to do, I can simply. 19 00:01:17,310 --> 00:01:22,530 Fight mode to do element and directly goes over to this spot. 20 00:01:23,040 --> 00:01:29,520 And this is amazing because it really helps me to navigate through my files. 21 00:01:29,670 --> 00:01:34,500 In this case, it's super easy because I only have two documents, but once I have many different documents, 22 00:01:34,860 --> 00:01:36,180 this will come in very handy. 23 00:01:36,780 --> 00:01:43,830 Other than comments with just two slashes, we can also create multi-line comments by by using a slash 24 00:01:43,830 --> 00:01:45,740 and then a asterisk. 25 00:01:46,050 --> 00:01:46,260 OK? 26 00:01:46,800 --> 00:01:47,340 And with. 27 00:01:48,610 --> 00:01:56,380 That's it automatically creates the closing comment or the ending comment, which is an asterisk with 28 00:01:56,710 --> 00:02:00,550 a slash, so everything in between here will be a comment. 29 00:02:00,760 --> 00:02:04,180 This is a comment. 30 00:02:04,840 --> 00:02:07,570 So this is a multi-line comment to be precise. 31 00:02:07,570 --> 00:02:10,539 Multi line comment. 32 00:02:12,330 --> 00:02:18,060 All right, so just so you know how you can create comments and what they do, so they don't have any 33 00:02:18,060 --> 00:02:23,310 impact onto our program, on the execution time, on the compiling time. 34 00:02:23,430 --> 00:02:26,580 None of that is just for us as a developer. 35 00:02:27,720 --> 00:02:30,630 All right now, let's have a look at other variable types. 36 00:02:30,960 --> 00:02:35,160 I told you that Caitlin is a typed language. 37 00:02:35,580 --> 00:02:44,940 This means but every variable is of a specific type and type inference as a concept that allows us to 38 00:02:45,240 --> 00:02:51,120 just assign a value to a variable and Kotlin will know of which type that variable will be. 39 00:02:51,570 --> 00:02:54,510 So, for example, it knows that this is of type string. 40 00:02:55,020 --> 00:03:03,930 If I create another variable, let's say my h and I assign 31 to it, then this my h variable will be 41 00:03:03,930 --> 00:03:04,350 of type. 42 00:03:04,350 --> 00:03:06,300 String will be of type event. 43 00:03:06,840 --> 00:03:07,200 So. 44 00:03:08,560 --> 00:03:13,570 This is an event, and this year is a string. 45 00:03:14,260 --> 00:03:22,870 All right, it's are used for whole numbers and they require a certain amount of space in our memory. 46 00:03:24,230 --> 00:03:28,400 For example, an integer requires 32 bits of memory. 47 00:03:29,420 --> 00:03:32,870 If we want to use other types, they're available as well. 48 00:03:33,350 --> 00:03:36,440 So I'm just going to paste in some other types in here. 49 00:03:36,740 --> 00:03:44,190 For example, there is this type called byte, then this type called short, the type called end and 50 00:03:44,210 --> 00:03:45,410 type called long. 51 00:03:46,070 --> 00:03:52,190 And all of them are integer types and integer types are whole numbers. 52 00:03:52,700 --> 00:03:56,900 And each of them requires a different amount of space. 53 00:03:57,350 --> 00:04:05,420 So, for example, a byte is just eight bits, requires a bits in the memory, a short requires 16 bits 54 00:04:05,420 --> 00:04:09,890 in memory and 32 bits and long 64 bits. 55 00:04:10,760 --> 00:04:13,460 Now here it says the value is out of range. 56 00:04:13,550 --> 00:04:17,779 So this value is too long for even a long value. 57 00:04:18,200 --> 00:04:23,450 So if you have a very long number, this could be used, for example, for a Social Security number 58 00:04:23,450 --> 00:04:28,620 or for a credit card number, then you could use it long and here. 59 00:04:29,090 --> 00:04:31,430 Actually, it doesn't fit like this anymore. 60 00:04:31,580 --> 00:04:34,730 So I stood like that. 61 00:04:37,260 --> 00:04:39,090 And then we have a super long number here. 62 00:04:39,840 --> 00:04:44,940 Now you might wonder, why is this bytes dropped short and where are all of these coming from? 63 00:04:45,420 --> 00:04:47,970 Well, they come from me answering them. 64 00:04:48,150 --> 00:04:54,270 So here I explicitly say this variable called my byte should be of type byte. 65 00:04:54,630 --> 00:04:55,380 How do you do that? 66 00:04:55,500 --> 00:05:00,240 Well, I can do that by using the colon and afterwards to type. 67 00:05:01,230 --> 00:05:08,640 But of course, if I use a byte type, I can not use a long number because note will say. 68 00:05:09,670 --> 00:05:13,480 The integer literal does not conform to the expected Typekit. 69 00:05:14,050 --> 00:05:22,630 This means that the value that I entered here is so long that it's usually an integer, but we are trying 70 00:05:22,630 --> 00:05:27,910 to store it in a byte variable and that doesn't work because an integer needs a lot more space than 71 00:05:27,910 --> 00:05:28,360 a bite. 72 00:05:28,810 --> 00:05:33,940 So we need to make sure that the value that we assign here is correct. 73 00:05:34,480 --> 00:05:36,790 Now, at the same time, we don't need to do that. 74 00:05:37,090 --> 00:05:38,530 You see, I do that here. 75 00:05:38,620 --> 00:05:39,670 I say, this is a bar. 76 00:05:39,700 --> 00:05:40,690 This is a short isn't. 77 00:05:40,890 --> 00:05:43,210 This isn't long, but we don't need to do that. 78 00:05:43,210 --> 00:05:43,900 You saw it here. 79 00:05:44,230 --> 00:05:51,010 I just assigned a value 31 and that will automatically assign the right data type. 80 00:05:51,700 --> 00:05:56,890 And usually, if you don't explicitly say that you want to have a byte or short, it will just assign 81 00:05:57,610 --> 00:05:58,300 an integer. 82 00:05:58,750 --> 00:06:01,180 Cotton will just assume that this is an integer. 83 00:06:01,660 --> 00:06:02,380 How do you know that? 84 00:06:02,470 --> 00:06:07,930 Well, you can just enter my h, and you can see here on the right hand side that it is an integer. 85 00:06:08,170 --> 00:06:08,590 So. 86 00:06:09,790 --> 00:06:16,690 Scotland did the magic for us, and it automatically assigned to Typekit, which is called or does approach 87 00:06:16,690 --> 00:06:19,210 here is called type inference. 88 00:06:20,020 --> 00:06:24,640 So it just inferred to type based on whatever value we assign to it. 89 00:06:25,240 --> 00:06:28,540 Of course, if we do so, then we have to assign a value to it. 90 00:06:29,200 --> 00:06:33,220 So I cannot just create who are my age without assigning a value to it. 91 00:06:33,310 --> 00:06:35,470 I need to assign a value to it. 92 00:06:37,560 --> 00:06:39,690 There are a bunch of other types as well. 93 00:06:40,140 --> 00:06:42,810 So these are the integer types that we looked at. 94 00:06:43,170 --> 00:06:46,530 Now let's look at the floating point number types. 95 00:06:46,740 --> 00:06:50,610 So there are types which are required for floating point numbers. 96 00:06:50,880 --> 00:06:55,830 For example, the floating point number types float, which is a 32 bit. 97 00:06:57,200 --> 00:07:00,200 Data type and double, which is a 64 bit data type. 98 00:07:00,680 --> 00:07:06,650 Now here I'm assigning one three or thirteen point thirty seven to my flawed variable, which I called 99 00:07:06,650 --> 00:07:08,960 my flawed, but it's still complaining. 100 00:07:09,200 --> 00:07:10,310 So what's wrong here? 101 00:07:10,670 --> 00:07:17,360 Well, if I assign a floating point value, it usually assumes that I want to assign a double. 102 00:07:17,600 --> 00:07:26,030 As you can see here, but if I explicitly only want to use a float which has a lower range, so which 103 00:07:26,420 --> 00:07:28,550 just can't be as long as that of a number? 104 00:07:28,910 --> 00:07:34,160 Then I have to explicitly state that by adding an f at the end, this f stands for float. 105 00:07:34,430 --> 00:07:39,140 So I'm just saying, okay, this variable should be of type float or this value that I'm assigning here. 106 00:07:39,500 --> 00:07:47,180 So if I should get rid of this, for example, and I now check my float, you will see that it is a 107 00:07:47,180 --> 00:07:47,540 float. 108 00:07:48,380 --> 00:07:48,860 All right. 109 00:07:48,890 --> 00:07:54,140 So if I get rid of this f and I check what my float is, you can see now it's a double. 110 00:07:54,670 --> 00:08:01,730 And that has to do with me assigning this f to it and explicitly stating that it should be a float. 111 00:08:03,700 --> 00:08:07,330 So if you really need to save space, you can use floats. 112 00:08:07,540 --> 00:08:15,070 If the numbers are not going to be huge, but if you need flexibility, long numbers or you just don't 113 00:08:15,070 --> 00:08:16,960 care about space, then you can use doubles. 114 00:08:17,230 --> 00:08:22,960 And generally speaking, doubles are preferred by Scotland, or they will be most of the time use if 115 00:08:22,960 --> 00:08:25,480 you don't explicitly state that it's going to be a float. 116 00:08:26,950 --> 00:08:32,559 Using floats is important, for example, when you develop video games and you want to calculate the 117 00:08:32,559 --> 00:08:39,669 physics, then having as fast as possible calculations will be more important than having super duper 118 00:08:39,669 --> 00:08:40,270 precision. 119 00:08:40,630 --> 00:08:42,549 So that's where flood comes into play. 120 00:08:42,970 --> 00:08:45,790 But most of the time, stubble will be your way to go. 121 00:08:46,270 --> 00:08:46,570 All right. 122 00:08:46,570 --> 00:08:49,660 So these are the number types, but there are other types as well.