(calm music)
-: Okay, so we were able to run this code
and we understood something
what is happening behind the scenes, right?
So basically we know now that as a programmer,
as a Java developer, you write our Java code,
which will be having dot Java extension
and that gets compiled by Java C.
And then when you compile the code,
what you get in output is a byte code
which will be having dot class file.
And then you can run the dot class file in your JVM
and basically it's a part of JRE which will have JVM
as well as a libraries, a lot of classes.
And then everything is a part of a JRE,
that JRE you'll be installing on OS, right?
So basically you need to have a hardware,
of course you need a machine to run, right?
That machine will be having an OS
and that OS will be having JRE, which is,
which will have JVM.
But as a developer you will need one more tool,
which is JDK.
Now when you install a new JDK,
you get the updated JRE and JVM with it, okay.
So the version of JDK which we are using is JDK 17,
which is LTS, which is long-term support.
And in every new version you
get some minor extra features, right?
So even if you are watching this after 10 years
or eight years or five years,
you'll be having new version of Java.
Of course next five years you will get 10 new versions
and every new version will have minor updates,
but the base thing remains same, right?
So whatever you're learning is actually
from Java one itself.
The system.printer is same in Java 1.
So don't worry about the new updates,
the core concept will remain same.
Okay, cool.
Now once you have this thing, what next we can do?
Now think about this world, of course.
First of all, why we build software, we build software so
that we can solve a problem.
Now what problem we are trying to solve?
So basically we are trying to solve the real world problems
with the help of virtual world.
Example, you wanted to buy something.
So you got Amazon, which delivers everything at home.
So you got Amazon as online service, you wanted
to book a cab, you got Uber.
So for every problem we have a solution
in the virtual world, right?
So banking, everything is happening online.
Now when you say you are replacing the real world
with a virtual world solution,
so basically we need to work with one thing.
The most important thing now is actually data.
So basically we want to work with data.
So how will you work with data?
So basically you need data as well as processing on it.
So whatever, when you build, we build a project.
Or when you build application,
what we are doing is we are doing the processing on data.
Now this data can be coming from user
or something, so maybe you will accept the data
from the user and then you will do some work with it.
Maybe you want to store this data.
Now where exactly do we store data?
So we store data in something called database.
So we have a database here
in which you'll be showing your data.
So whatever data you're getting from the user
or from after processing.
So let's say we've got a user here, user sends us data,
we will apply a processing on that.
So we will do some work in between.
And then at the end we might store data in database.
Now this database is actually a permanent storage
or a persistent storage, which you say.
Now when you say it is permanent,
that doesn't mean you can't change it.
Of course you can, you can replace the values as well,
but then the data stays there, okay?
So if you just store it
and if even if you shut down your machine,
the data will be stored.
Example, when you copy movies
or games on your laptop, it stays there, right?
It'll get deleted when you say delete,
but the data stays there.
So this makes sense, right?
But when I say you will receive data from the user
and then you will be doing some processing on that
where you will store the data for temporary purpose.
Of course database is there for permanent storage,
but during processing you have to store your data somewhere
and that somewhere is variable.
So this is where you store your data. Now what is variable?
So imagine variable as a box
and in this box you will store your data.
Now what data you want to store?
Your data can be numeric,
it can be text, it can be image, whatever you want to store.
So you can store that data in this variable.
Now I'm not talking specific to Java in general,
when you say you want to store data, you will store
that in a box and that box will have a type to it.
It can be of type numbers, it can be of types, text
or image or video.
So here we are trying to store data, right?
So let's say I want to store the number which is 5.
So this box will have a number 5
and it'll also have a name to it.
Maybe I can give a name. Let's say a number.
It doesn't matter what name you give,
of course there are some restrictions on names.
But num works, you can use any name in which you like.
Maybe you can create one more box here
and you want to store the number itself,
but let's say a decimal value, something like 6.5,
you can do that, okay?
And maybe you can have a different value to it,
different name to it.
Maybe you can say marks or grades.
Maybe you want to have one more box
where you want to store your name.
So I can do that, I can store my name as Navin
and it'll have a variable name.
So maybe I can say this is user. So user is Navin.
So basically what you do is you create a box
and inside the box will be having values.
Now this box are actually called variables.
So we can name this box as a variable, okay?
And so what we got till now we got
that a box will be called a variable
and you'll be having a name to it, you'll be having a value.
So name and value will be there.
Apart from that,
you know Java is actually called strongly typed language.
Now what it means is whatever variable you want to create.
So if you want to store the data,
of course Java says, "Hey, we'll accept the data,"
but tell me also what kind of box you want.
A different type of data will require different box.
Okay, that makes sense.
So I will say, "Hey Java, I want to store a number.
So I want you to create a box
for me which will accept numbers."
So we can say, okay, this makes sense, number will go there.
We can also create this as a number,
but this is a text, right?
So in Java we call them as a string, right?
So text will be having a string. So this box type is string.
What about this box?
Of course we say this is a number, this is also a number,
but in number as well we have a category inside it.
So one of the category I will mention is this, we can,
if you want to store numbers, we can store
that in something called int.
Now int means integer, okay?
So we can store data in the integer format,
but we cannot store 6.5 in int because 6.5 is a real number.
So int will accept numbers,
but why is called int we not natural numbers
or whole numbers is because maybe you want
to store negative values as well.
So remember your maths concept.
So we have negative numbers to positive values.
So everything will be considered as int
so we can store minus 5 plus 5.
That's your choice. Okay, so this makes sense.
So what I will do now is if I go back to the code,
of course we want to print "Hello World",
but we have done that.
Now I want to store value so
that I can do some processing on it.
Now what kind of processing I want to do, maybe I can,
I want to add two numbers, maybe 2 plus 2
or 5 plus 6, simple stuff, right?
But before that we'll see how do we store data?
Even if you don't store data, you can just go
inside this System.out.print,
whatever operation you want to perform, you want
to say 3 plus 5, that will work.
So you can just go back here and say compile and run.
So remember this thing every time you make a change, just
make sure that you compile it first.
So the first step is compilation and then running.
And you can see we've got the output which is 8.
Just ignore this percentage symbol as of now.
Actually there's one more thing I wanted to mention.
Whenever you print something, let's say I want
to print this number here as well.
I want to perform different options.
So you can write multiple statement
for different operation you want to perform.
So you can say 8 plus 7.
So we are doing addition here
and then addition here, let's clear the screen.
Okay, first compile, okay, that's what.
Compile run and you can see we got the value.
Now the only thing you can see is the result
are bit, they're together, right?
We want to give a space of maybe I can
print 15 on new lines.
So what you can do is instead of using print,
you can actually use something called println.
Now println means print new line.
So it'll print and it'll go on new line.
So we can do that here as well.
So just say ln, ln at the end, println,
which is print new line and now compile run
and you can see we got the value, we got 5 and 15.
So from now we'll not be using print,
we'll be using ln, println.
Okay, so again println means it'll
print, it'll go on new line.
So we got println. Now what else we can do here?
So I don't want to perform the operation here, remove that.
I want to store that value first. So how do we store?
Of course we need box, right?
So I can say num1, I can, as I mentioned,
I can use any variable name.
So let's say num1 or to start with let's say num, just
to keep it simple and then we can give a value to it.
Let's say value is 3.
So remember you have
to mention the variable name and then we have
to mention the value for it.
And at the end of course you can put a semicolon.
So we can say we got num equal to 3
and we got a semicolon.
So in Java, after every statement you have
to give a semicolon.
You might be thinking, hey, why don't we
have a semicolon here?
It's because that is a block.
So we don't put a semicolon out at the end of a block.
The reason is it signifies that's the end.
Here, if you don't mention semicolon,
how do we define that that's the end?
So it's good to put semicolon at the end.
And anyway, Java will give you if you don't do that.
The next thing we have to do here is we have
to also mention the type, what type of num is this?
So we can say int.
Now we have to say first you have to specify the type
and then you mention the variable name.
Maybe if you have learned some other languages
where you put the type afterwards, in Java,
we first put the type
and then we put the name, then we assign the value.
Now this equal to here is called assignment operator
because you are assigning a value.
So what it'll do is it'll take the value
from the right hand side,
it'll assign the value to the left hand side, okay?
Remember this, equal to will take the value
from the right hand side,
it'll assign the value to the left hand side.
Okay, so we got a variable which is of type int. Okay?
So this is num, which is a variable
and then we can print it.
Now, let's only print the value. That's it, nothing much.
I'll just save.
Now once you click on save, you have
to compile the code and run the code
and you can see we got 3.
Okay, cool. So now can I create more variables?
We can actually, so let me just rename the value variable
from num to num1 and here as well, I'll print num1.
Okay, and then I will create one more variable,
which is num2 is equal to.
So every time you want to get a variable,
just mention the type which is int
of whatever type of variable you're creating.
At this point we are working with numbers.
So we'll say int num2 equal to.
We can assign the value, which is 5.
So we got 3 and 5.
Here, what you can do is you can actually
perform the operation here itself.
So you can say number one plus num2, that works.
So instead of adding values, we can also add the variables.
Okay, so now we are, what we're doing is we are saying num1
plus num2 and the addition be getting printed.
Let's try.
So I can just go back here and say compile run,
and you can see we got 8.
You know what, instead of adding it
inside this, it's not a good practice.
What you can do is we can
create another variable called result.
And that's right, variables are free to use.
Of course, behind the scenes it's consuming a lot of memory,
but it's working right as of it's free as of now.
But later on we'll focus on
how can you make your code more efficient so
that it'll use less space, right?
At this point it works. So we can say num1 plus.
So whatever option you want to perform,
you can do that here.
And instead of printing doing addition here,
we can simply print result.
So what you're doing now is you are adding the value
and then you are storing that in a result
and then you are printing it.
It should work. Let's try compile run.
And you can see we got 8. So this is working.
So that's how you can create variables.
So remember this thing.
Every time you want to create a variable,
you first need a name for it, at this point is num1.
You have to also mention the type of it.
At this point, this is int
and you have to assign the value for it.
In the upcoming videos we'll talk about how can you
create a variable, which will be having a name
with a different type and different value.
Okay? So that's it from this video.