‫Instructor: Hi, we have been working with variables
‫for some time, and one of the reasons that we call them
‫variables is that we can vary the value
‫after we create them.
‫For example, we have changed the double z,
‫if you remember to before,
‫after we have initialized it with five.
‫We can do that with any variables that we want,
‫but if we cast them as final,
‫if we create them with final keyword,
‫that means that it cannot be changed.
‫So let me show you what I mean.
‫Let me create an integer called myInteger.
‫And it's five.
‫Then I can just call my integer
‫to be any other value whenever I want, okay?
‫Now, if I run this, okay?
‫If I print out my integer over here, it will be run,
‫and it will be showing the value of five to me.
‫For example, let me do it like this, myInteger, okay?
‫And + myInteger.
‫So this will show me the results of my integer.
‫And one of the most important things that you should know
‫is that these codes are run in order.
‫So right now I'm seeing my my integer is five,
‫and if I do it here, okay?
‫If I write the exact same thing
‫now I will see my integer is four in the logs,
‫because these are run in order.
‫As you can see, my integer was five,
‫there I changed it to four, and I printed out as four.
‫But if I add final keyword over here,
‫then I cannot change the value
‫of my integer at this point on.
‫As you can see it says that you cannot assign a value
‫to a final variable.
‫So this is kind of a constant,
‫it cannot be changed after all.
‫So you cannot do that once you declare a variable final.
‫So if you have in a case like this
‫that you have to create a variable
‫and you don't want the value to be changed after all,
‫then you should mark it with final keyword.
‫If it's not the case, then you shouldn't bother
‫with the final keyword at all.
‫So most of the time we don't want this,
‫because we may want to change the value,
‫but if you come across in a situation like this
‫and if you see a final keyboard,
‫it means that it's a constant,
‫It shouldn't be changed after all, and you cannot do that.
‫As you can see, if we try to run this, we will get an error.
‫So here you go.
‫Now you know what's a variable,
‫you know what's a constant,
‫or at least you know what's a final keyword.
‫Now we can move on with the other data structures.