And this lecture, I will explain every single word in the code we wrote in the previous video.
So this code is to display may the force be with you.
OK, so first we created a class, then we added the main method to it.
And last we added a command that printed out this sentence.
Now, let's start with some main parts of the code.
First of all, keywords, Java has many keywords.
And A.J., they are highlighted with the style of Scientology.
They are orange.
They must be used in a specific order.
Also, they are case sensitive.
So public with lower case doesn't equal to public, starting with an uppercase.
OK, let's move from the top to the bottom.
So public public is an access modifier, which defines how other parts of the code can use this code
block besides public.
There are other access modifiers to like private, protected and packaged private.
But more on this later.
The next keyword is Klasky word.
It is just used to define a class.
After that, the name of the class, which is the same as the name of the file after the class name
Curly Braces, defines the scope, the area, the territory of the class or the code inside the curly
braces belongs to the class.
So just to summarize this, to define a class, you need to have an X modifier, which is optional then
the class keyword, which is mandatory.
And finally, the name of the class with the curly braces.
Now let's move on to the main method.
So what our methods methods are used to group together operations connected to each other.
Methods also have a name.
And by using that name, you can run the operations in the method from several different places.
So it is a very good tool to make your code reusable.
Also, they make your code more readable because the operations connected to each other grouped into
one single unit in other programming languages, methods, maybe court procedures or functions.
Now let's move on to the main method.
It is a special method.
It is a starting point for running Java programs.
So when you run your Java code, it starts from the main method and runs and uses code that is written
here and used to other classes.
So let's go into some details public.
As I said, it is an axis.
Modifier static shows that this method belongs to the class rather than the object that you can create
from this class.
To understand this.
First you need to know classes and objects and the difference between the two concepts.
Don't worry, it is not rocket science.
I will make it all clear later in the course.
Now let's move on to the next keyword void.
Void means that this main method doesn't return anything, a number or text or something else.
It simply runs an action.
Like here a text is printed out to the screen.
OK, the next one is Main, which is the name of the function then to parentheses, which shows Java
that it is a function.
And in the parentheses there are parameters like here string square brackets, args string square brackets,
which is an array, a list of text and ARGs is the name of that list.
Here you can see how it would look like if we would store values in the args array.
We use the name and then square brackets than a number in the square brackets to get the element of
this array.
We will look more into this later in the arrays lectures and lost the curly braces that belong to the
main method which shows the scope of the main method.
So every command between these curly braces belongs to the main method.
OK, so the last part of this code is the system that ordered print online and the text.
So what is system?
What is out and what is print?
Alarm system is an inbuilt class of Java and it represents your computer system.
Then out is a field, an attribute in a system which is responsible for the outputs.
For example, to show something on the screen and print plan or print line is a method or function of
out.
It prints out one single line.
The parentheses show that this is a function and its parameter is the text we would like to print out
between two double quotes.
One last thing here is the semicolon at the end of the line.
It is a must for every single command, but you don't have to use it at the definition of classes or
methods.
If you miss it, Java will warn you that the semicolon is missing from the end of the line.
Let's give it a try now.
I'm going to delete this semicolon here and let's run the code.
And as you can see, a semicolon is missing from the end of the line, and Java expected a semicolon
there.
If you click somewhere else and you click on this error message here, the cursor will jump right to
the place where the semicolon should be.
And if I add a semicolon again and I run the code again.
You can see it is running again and we got zero exit code, so what I suggest you to do here is to print
out something else and also change the order of the key words just to explore what air or message you
can get.
Don't worry, you cannot do any harm.
It is just code.
You can always find the code of the lecture next to the lectures title as a resource.
All right.
That's it.
See you in the next lecture.