1 00:00:01,280 --> 00:00:05,910 And this lecture, I will explain every single word in the code we wrote in the previous video. 2 00:00:06,350 --> 00:00:09,470 So this code is to display may the force be with you. 3 00:00:09,830 --> 00:00:15,260 OK, so first we created a class, then we added the main method to it. 4 00:00:15,560 --> 00:00:19,640 And last we added a command that printed out this sentence. 5 00:00:20,120 --> 00:00:22,890 Now, let's start with some main parts of the code. 6 00:00:23,510 --> 00:00:27,230 First of all, keywords, Java has many keywords. 7 00:00:27,230 --> 00:00:31,260 And A.J., they are highlighted with the style of Scientology. 8 00:00:31,400 --> 00:00:32,410 They are orange. 9 00:00:32,900 --> 00:00:35,400 They must be used in a specific order. 10 00:00:35,720 --> 00:00:37,850 Also, they are case sensitive. 11 00:00:38,000 --> 00:00:44,090 So public with lower case doesn't equal to public, starting with an uppercase. 12 00:00:44,660 --> 00:00:47,080 OK, let's move from the top to the bottom. 13 00:00:47,540 --> 00:00:55,250 So public public is an access modifier, which defines how other parts of the code can use this code 14 00:00:55,250 --> 00:00:56,970 block besides public. 15 00:00:56,990 --> 00:01:02,600 There are other access modifiers to like private, protected and packaged private. 16 00:01:03,200 --> 00:01:04,500 But more on this later. 17 00:01:05,000 --> 00:01:07,130 The next keyword is Klasky word. 18 00:01:07,760 --> 00:01:10,280 It is just used to define a class. 19 00:01:11,190 --> 00:01:17,940 After that, the name of the class, which is the same as the name of the file after the class name 20 00:01:18,420 --> 00:01:26,130 Curly Braces, defines the scope, the area, the territory of the class or the code inside the curly 21 00:01:26,130 --> 00:01:28,270 braces belongs to the class. 22 00:01:28,710 --> 00:01:35,760 So just to summarize this, to define a class, you need to have an X modifier, which is optional then 23 00:01:35,910 --> 00:01:38,460 the class keyword, which is mandatory. 24 00:01:38,670 --> 00:01:42,180 And finally, the name of the class with the curly braces. 25 00:01:43,110 --> 00:01:45,020 Now let's move on to the main method. 26 00:01:45,120 --> 00:01:52,050 So what our methods methods are used to group together operations connected to each other. 27 00:01:52,770 --> 00:01:54,630 Methods also have a name. 28 00:01:54,930 --> 00:02:01,850 And by using that name, you can run the operations in the method from several different places. 29 00:02:02,340 --> 00:02:05,950 So it is a very good tool to make your code reusable. 30 00:02:06,720 --> 00:02:13,620 Also, they make your code more readable because the operations connected to each other grouped into 31 00:02:13,620 --> 00:02:20,400 one single unit in other programming languages, methods, maybe court procedures or functions. 32 00:02:21,180 --> 00:02:23,520 Now let's move on to the main method. 33 00:02:24,150 --> 00:02:25,650 It is a special method. 34 00:02:25,770 --> 00:02:28,700 It is a starting point for running Java programs. 35 00:02:28,980 --> 00:02:36,240 So when you run your Java code, it starts from the main method and runs and uses code that is written 36 00:02:36,240 --> 00:02:39,200 here and used to other classes. 37 00:02:39,840 --> 00:02:42,700 So let's go into some details public. 38 00:02:42,720 --> 00:02:44,340 As I said, it is an axis. 39 00:02:44,340 --> 00:02:51,810 Modifier static shows that this method belongs to the class rather than the object that you can create 40 00:02:51,810 --> 00:02:52,890 from this class. 41 00:02:53,520 --> 00:02:54,640 To understand this. 42 00:02:54,840 --> 00:02:59,910 First you need to know classes and objects and the difference between the two concepts. 43 00:03:00,210 --> 00:03:02,280 Don't worry, it is not rocket science. 44 00:03:02,590 --> 00:03:05,320 I will make it all clear later in the course. 45 00:03:06,030 --> 00:03:08,610 Now let's move on to the next keyword void. 46 00:03:09,210 --> 00:03:17,520 Void means that this main method doesn't return anything, a number or text or something else. 47 00:03:17,950 --> 00:03:19,710 It simply runs an action. 48 00:03:19,710 --> 00:03:22,740 Like here a text is printed out to the screen. 49 00:03:23,490 --> 00:03:31,380 OK, the next one is Main, which is the name of the function then to parentheses, which shows Java 50 00:03:31,710 --> 00:03:33,390 that it is a function. 51 00:03:33,750 --> 00:03:42,150 And in the parentheses there are parameters like here string square brackets, args string square brackets, 52 00:03:42,150 --> 00:03:48,230 which is an array, a list of text and ARGs is the name of that list. 53 00:03:48,720 --> 00:03:54,110 Here you can see how it would look like if we would store values in the args array. 54 00:03:54,780 --> 00:04:03,150 We use the name and then square brackets than a number in the square brackets to get the element of 55 00:04:03,150 --> 00:04:03,920 this array. 56 00:04:04,590 --> 00:04:11,430 We will look more into this later in the arrays lectures and lost the curly braces that belong to the 57 00:04:11,430 --> 00:04:15,110 main method which shows the scope of the main method. 58 00:04:15,300 --> 00:04:19,830 So every command between these curly braces belongs to the main method. 59 00:04:20,340 --> 00:04:26,250 OK, so the last part of this code is the system that ordered print online and the text. 60 00:04:26,790 --> 00:04:28,380 So what is system? 61 00:04:28,380 --> 00:04:30,180 What is out and what is print? 62 00:04:30,180 --> 00:04:36,380 Alarm system is an inbuilt class of Java and it represents your computer system. 63 00:04:36,810 --> 00:04:43,230 Then out is a field, an attribute in a system which is responsible for the outputs. 64 00:04:43,920 --> 00:04:52,110 For example, to show something on the screen and print plan or print line is a method or function of 65 00:04:52,110 --> 00:04:52,590 out. 66 00:04:53,310 --> 00:04:55,560 It prints out one single line. 67 00:04:56,160 --> 00:05:03,060 The parentheses show that this is a function and its parameter is the text we would like to print out 68 00:05:03,060 --> 00:05:04,560 between two double quotes. 69 00:05:05,100 --> 00:05:08,820 One last thing here is the semicolon at the end of the line. 70 00:05:09,150 --> 00:05:15,570 It is a must for every single command, but you don't have to use it at the definition of classes or 71 00:05:15,570 --> 00:05:16,230 methods. 72 00:05:16,680 --> 00:05:22,230 If you miss it, Java will warn you that the semicolon is missing from the end of the line. 73 00:05:22,570 --> 00:05:23,880 Let's give it a try now. 74 00:05:23,880 --> 00:05:28,260 I'm going to delete this semicolon here and let's run the code. 75 00:05:32,660 --> 00:05:38,270 And as you can see, a semicolon is missing from the end of the line, and Java expected a semicolon 76 00:05:38,270 --> 00:05:38,600 there. 77 00:05:38,940 --> 00:05:46,550 If you click somewhere else and you click on this error message here, the cursor will jump right to 78 00:05:46,550 --> 00:05:49,010 the place where the semicolon should be. 79 00:05:49,760 --> 00:05:54,440 And if I add a semicolon again and I run the code again. 80 00:05:58,890 --> 00:06:06,690 You can see it is running again and we got zero exit code, so what I suggest you to do here is to print 81 00:06:06,690 --> 00:06:13,680 out something else and also change the order of the key words just to explore what air or message you 82 00:06:13,680 --> 00:06:14,310 can get. 83 00:06:14,520 --> 00:06:16,720 Don't worry, you cannot do any harm. 84 00:06:16,740 --> 00:06:17,700 It is just code. 85 00:06:18,000 --> 00:06:23,310 You can always find the code of the lecture next to the lectures title as a resource. 86 00:06:24,150 --> 00:06:24,890 All right. 87 00:06:24,900 --> 00:06:25,510 That's it. 88 00:06:25,680 --> 00:06:27,090 See you in the next lecture.