Learn Java variables and data types, including how to declare variables, assign values, and understand the importance of data types in Java programming.
Ask about this video. Answers come from its transcript only — with the timestamp, so you can check them.
Generated from the transcript and can be wrong — check the timestamp.
Key Takeaways
- Variables are containers that hold data values which can change.
- Every variable in Java must be declared with a specific data type.
- Data types define the kind of data a variable can store, such as int for integers or String for text.
- Understanding variables and data types is essential before moving to advanced Java concepts.
- Java does not allow assigning values to variables without declaring their data type first.
What the video covers
- Introduction to Java variables as containers that hold data values.
- Explanation of variables representing data that can change over time.
- Examples of variables storing different types of data like numbers, strings, and decimals.
- Importance of specifying data types when declaring variables in Java.
- Common data types in Java such as int, String, and float.
- Variables must be declared with a data type before assigning values.
- Data type determines the kind of data a variable can store.
- Variables and data types are foundational concepts for learning Java programming.
- Upcoming topics include conditional statements, loops, arrays, and strings.
- Practical examples of variable declaration and usage in Java.
Full Transcript — Download SRT & Markdown
Speaker A
Okay, so can you see my screen, everyone? Okay, all right. So in yesterday's class, we have started Java programming. So as part of it, we have seen the introduction, and then we have seen how we can install Java and Eclipse IDE. So we already installed and also seen a basic program, right? How to start creating a new Java project, and then we have seen how to create a new Java package, and then we have seen how to create a new class.
Speaker A
Java and Eclipse ID so we already installed and also seen uh a basic program right how to start creating a new Java project and then we have seen how to create new Java package and then we have seen how to create a new class
Speaker A
And the simple programs we have seen. So from today onwards, we are going to start learning new concepts, so Java basics. And in any programming, if you want to start learning, we need to start first with variables and how to create variables and how to use different data types, how to work with the data, which is most important. So when you start Java, also first we need to understand what is variables and how to define the variables and how to use data types.
Speaker A
create variables and how to use different data types how to work with the data which is most important so when you start Java also first we need to understand what is variables and how to define the variables and how to use data
Speaker A
And then we will slowly learn how to use conditional statements, looping statements, arrays, strings, and so on. Okay, so as part of today's session, we will start learning variables and data types. So what is a variable first of all? So a variable is a container which can hold some data. So whenever you want to write some program, we want to deal with some data. So to store data, we use something called variables. Variable is nothing but it is a character or we can say a letter which can hold some data. It is representing data.
Speaker A
all so variable is a container which can hold some some data so whenever you want to write some program we want to deal with some data so to store data we use something called variables variable is nothing but it is a character or we can
Speaker A
Okay, so to represent some data, we use something called variable. So for example, let us say I have to store a number. Let’s say in mathematics when I say x equal to 100. So 100 is what here? 100 is a value or we can say data, which we can store in a variable. So what is X here? X is a variable, and initially x value is 100. Then I can make x value 200. Now what is the value of x? The value of x will be 200. That means the values of the variable can also change every time. So we can change the values of variables every time. So that is the reason we can call them as variables. Variables means the value is always varies, means it is always change.
Speaker A
so 100 is what here 100 is a value or we can say data so which we can store in a variable so what is X here x is a variable and initially x value is 100 then I can make x value 200 now what is
Speaker A
So here x is a variable and 100 is a value. So for example, if you want to store a price, an item price, you bought one product and you want to store the price of an item, so then what you will do? You will create one variable like this: this item price equal to let's say 10025, something like this. Now here this is a value and item price is a variable.
Speaker A
call them as a variables variables means the value is always varies means it is always Chang so here x is a variable and 100 is a value so for example if you want to store uh a price an item price
Speaker A
So what is the use of this variable? Here is we can store some data in a variable. That means a variable is a container which can hold some data, which can hold some type of data. It can be number or it can be decimal or it can be string, it can be character, whatever it is. So the variable is a container which can hold some data. Whatever data we have assigned, we can hold the data in a variable. So variables are used to represent data. So normally whenever you say variable, that is always representing data.
Speaker A
is a value and item price is a variable so what is the use of this variable here is we can store some data in a variable that means a variable is a container which can hold some data which can hold
Speaker A
Okay, example: suppose I want to store age of the person. So normally what you will do? Age equal to let's say 30. So here this is a value and this is the variable. So suppose I want to store a name of the person, let's say name equal to some X. So here this is a value and this is a variable.
Speaker A
we can hold the data in a variable so variables are used to representing a data so normally whenever you say variable that is always representing a data okay example suppose I want to store age of the person so normally what
Speaker A
So what is the use of variable? Here we can store some data in a variable. So variable is a container which can hold some data which represents data. A variable represents some data. Okay, now in Java if you want to create a variable, we cannot directly create. For example, if you want to create variable like this x equal to 100, we cannot directly write like this in Java. And similarly, suppose if you want to store a name of the person, I can say name equal to say let's say John like this. I cannot directly store this value in the variable.
Speaker A
this is a variable so what is the use of variable here we can store some data in a variable so variable is a container which can hold some data which is represents a data a variable is represent some data okay now in Java if
Speaker A
So before creating this variable, we have to specify something called data type. Okay, something called data type. So what is the data type? So data type represents what type of data we are storing into the variable. What type of data we are storing into the variable, accordingly we have to specify the data type. For example, here 100 is a number and we are storing the 100 into X, so X should be int type of data. So int is a data type. Similar here John is a string, so we are storing string data in a variable, so this variable should be string. Similarly, suppose item price, I'm storing a decimal number here. So when I store decimal number, this variable should be float like this. So these are all called data types.
Speaker A
say name equal to say let's say John like this I cannot directly store this value in the variable so before creating this variable we have to specify something called data type okay something called data type so what is the data type so
Speaker A
So without having this data type, we cannot directly store the value in a variable. So whenever you create a variable, you must specify the data type. Now what is data type here? Data type is representing what type of data we are storing into the X. So we always work with variables along with the data type. So when I define some variable, you must specify the data type. So without data type, there is no variable. But how we will decide the data type depends on the data, what type of data we are storing into the variable. Accordingly, we will choose one data type and we can specify the data type for that particular variable.
Speaker A
so X should be int type of data so int is a data type similar here John is a string so we storing string data in a variable so this variable should be string similarly suppose item price I'm storing a decimal number here so when I
Speaker A
So later I will discuss what are the data types available and which one we have to use, where we have to use, all those things in detail. But first of all, let us talk about variables. We'll see some examples about variables, but when you create variables, you must specify the data type. Okay, so let me show you some examples here. I will specify some, I will define some variable with some data types.
Speaker A
data type now what is data type here data type is representing what type of data we are storing into the X so we always work with variables along with the data type so when I Define some variable you must specify the data type
Speaker A
So now if I suppose I can say x equal to 100, which is basically a number. So definitely X should be int data type. Int is nothing but an integer in Java. When I create a variable as int, we can store only numbers without having any decimal. Only numbers we can store. And similarly, if I want to store item price, item price let's say 10.25. This is a decimal number. If you want to store a decimal number, the data type should be float. And similarly, if you want to store age of the person, then the data type should be again int. And if you want to store name of the person, so basically it is a string. String means what? Collection of characters. So whenever you define a string, that should be put inside double quotations. This is Java syntax. In the double quotations, you can provide the string. String is nothing but collection of characters.
Speaker A
that particular variable so later I will discuss what are the data types are available and which one we have to use where we have to use all those things in detail but first of all let us talk about variables we'll see some examples
Speaker A
So now what is the type of this variable? It is string type of variable. Now I want to store a grade of a student. Grade is normally single character, a, b, c, something like this. So whenever you want to store a single character in a variable, that we should keep inside the single quotations. Let's say grade is a, that I can store like this. So now what is the type of this variable? It is char. So depends on data, what type of data we are storing into the variable, accordingly we have to select or we have to choose right data type here. These are all comes under different data types.
Speaker A
100 which is basically a number so definitely X should be int data type int is nothing but an integer in Java when I create a variable as int we can store only numbers without having any decimal only numbers we can store and similarly
Speaker A
Okay, now we'll see some example about the variables and then we will discuss in detail about the data types. Now go to Eclipse. And yesterday we already installed this Eclipse, and people who have joined today newly, please go through and please watch the yesterday session video. Okay, you will understand how to install Java and Eclipse.
Speaker A
be again in and if you want to store uh name of the person so basically it is a string string means what collection of characters so whenever you define a string that should be put inside the double quotations this is a
Speaker A
Now this is my project name, and this is my SRC, is a root package, and day one is another package, subpackage which we have created yesterday. Now I'm going to create another package under SRC, new package day two. So today I'm going to create another package. So package is nothing but what is it? Just like a folder. And here don't take package info.java, we don't need this. Simply specify the name of the package and say finish. So now it has created a new empty package.
Speaker A
grade is normally Single Character a b c something like this so whenever you want to store a single character in a variable that we should keep inside the single quotations let's say grade is a that I can store like this so now what
Speaker A
Now whenever you start writing a new Java program, what is the first thing we need to do? We have to create a new class. So right click on this package, new class, and here we have to provide the name of the class. Yesterday we have seen how to, what are the naming conventions which we have to follow while providing the class name, right?
Speaker A
types okay now we'll see some example about the variables and then we will discuss in detail about the data types now go to eclipse and yesterday we already installed this eclipse and people who have joined today newly please go through and please watch the
Speaker A
yesterday session video okay you will understand how to install Java and eclip now this is my project name and this is my SRC is a root package and day one is a another package sub package which we have created yesterday now I'm going to
Speaker A
create another package under SRC new package day two so today I'm going to create another package so package is nothing but what is a just like a folder and here don't take package info. Java we don't need this simply specify the
Speaker A
name of the package and say finish so now it is created a new empty package now whenever you start writing a new Java program what is the first thing we need to do we have to create a new class
Speaker A
so right click on this package new class and here we have to provide the name of the class yesterday we have seen how to what are the naming conventions which we have to follow while providing the class name right so here I'm giving some name
Speaker A
to class let's say variables demo and uh if you select this checkbox the main method will automatically included within the class and if you're not selected then it will just create a only class and inside the class we have
Speaker A
to write our own main method so let's select this option public static void Main and then click on finish you don't need to change any options here just provide only class name and Method public static requirement select this
Speaker A
check box and simply say finish that's it so it is now created a new class this is a package in which package we are in it will show you in the first line and this is the class name public class variables demo and
Speaker A
this is a starting point of the class and you can have this curly bra in the next line also no problem and within the class this is starting point of the class this is ending point or we can say
Speaker A
this is scope of the class and inside the class we have a method so this is called main method public static void main string ARS this is a parameter and this is simple comment we can just remove this so this is a structure now
Speaker A
once you write the structure we can start writing the program now where we have to write our code only inside the main method we have to write now I will Define some variables observe this very carefully there are many ways to create
Speaker A
a variables in Java so I will show you different approaches and different methods to create a variables and how to use those variables how to store the data we'll try to understand that first and then we will discuss data types so
Speaker A
to create a variable in Java first we have to specify the data type and then variable for example let's say in a and every statement will end with the semicolon in Java every statement will end with the semicolon so if I leave
Speaker A
like this I have not assign any data to this just I created a simple or single variable here int a I have not assigned any data so if you leave this variable like this without data we call it as a
Speaker A
just declaration we just declared the variables we have we haven't used it so far and we haven't assign any data to the variable we have just declar the variable so once you declare the VAR aable later you can use that variable
Speaker A
later you can assign the data into the variable for example in the next line I will assign the data like this and this is called assignment assignment so for declaring the variable I have written one statement for assigning the data into
Speaker A
the variable I have created another statement if I look at here int is a data type A is a variable so this is declaration I have not assigned any data later I have assigned some data to the variable a equal to 100 so when you're
Speaker A
assigning the data to the variable this variable is already declared here with the integer data type so when I Define the value in the variable or when you store the value in a variable you no need to write data Ty again it will give
Speaker A
you syntax error so why it is giving syntax error because this a is duplicate local variable duplicated means this variable is already created already declared with the integer data type so you no need to specify the data type
Speaker A
again like this a equal to 100 so this is called declaration this is called assignment sometimes we don't know the value but later we will try to assign the value in those cases what we can do we can simply declare the variables
Speaker A
later you can assign the data into the variables whenever you know the data you can assign it this is declaration another one is assignment now suppose I already know the value of the variable I can simply write one single statement
Speaker A
assignment declaration and assignment together I want to write one single statement so then what you can do I can just comment this now single statement int a equal to 100 one single statement data type variable and then value
Speaker A
statement end with the semicolon so this is single statement here what we have done declaration plus assignment we have done both the things in one single line declaration and then assignment now what is the value of a here 100 100 is a value of a now I want
Speaker A
to print it I want to get the value of a I want to just print the output value of a I want to print so what you can do now can say system. out.
Speaker A
pinell inside this you can just specify the variable so what will happen now we just specify only variable name variable means what it holds some data so what is the value of a00 so when I print a value
Speaker A
of a so this will print 100 you can see this is a value so a value is 100 we have assigned when you print the value of a we getting 100 and can we put this in the double codes
Speaker A
like this when you put the double codes what will happen now a is not a variable now it is just a string so when you run this what will happen it will just print as it is whatever you put in the double
Speaker A
quotations it's printed as it is okay we don't do like this so whenever you want to get the value from the variable or whenever you want to print the value from the variable you have to just specify the variable inside the print
Speaker A
statement system pin so then you will get the value from the variable like this now initially here a value is 100 and after that I have printed value of a then I want to change the value of a I
Speaker A
want to change is it possible to change this value later not here I have already Define the statement and I have printed some value from a now after printing the value of a then I want to change the
Speaker A
value of a yes still we can change how to change it simply can say a = to 200 and again you no need to write the data type here data type you don't need to write you should not write why
Speaker A
because this a is already specified with data type integer data type so second time when I trying to use this variable you know need to write the data type simply I can say equal to 200 now when you print a value here
Speaker A
what is an output you will get here initially a value 100 then we printed a value here and here it is got printed 100 now after that I'm changing a value equal to 200 and then I'm printing a
Speaker A
value here so because we already changed here here we will get a latest value so the old value is already replaced with the new value okay so if I print this initially 100 is got printed from this particular statement after that a become
Speaker A
200 then when I print a value here is printing 200 initially it is 100 now it becomes 200 so what we have understood based on this the values of the variable can always varies that means we can always change the value of the variables
Speaker A
whenever it is needed okay whenever it is needed we can always change the values of the variables they are not constant so this is a simple example how to create a variables and assign the data in one statement and we have get
Speaker A
the value from the variables now I will show you different approaches to create a variables let's come this part now let me show you different approaches or different methods to create a variables there a First approach let's say approach
Speaker A
one so I'm def I'm trying to Define some variables here let's say in AAL to 100 this is one variable semicolon int B = to 200 this is another variable in Cal to 300 this is another variable so totally how many variables I
Speaker A
have Define three variables a b and c a contains 100 B contains 200 C contains 300 three variables with three different values now I can directly print a value B value C value by using print statement so this is one approach we can directly
Speaker A
Define the different variable names we can directly assign the data this is one approach now same thing we can do in another way just observe here in first approach what I have done to Define three variables I have written three different lines first
Speaker A
in a = 100 in B 200 C300 now if I look at this one approach two see this in the second approach observe first I will create a variables in a comma B comma C all three are belongs to same data
Speaker A
type right so instead of writing this data type into multip multiple times I can simply write only one time and specify what are all variables I want to create say in a comma B comma C you can create any number of variables like this
Speaker A
by separating comma after that I will try to assign the data so a equal to 100 B = 200 C = 300 like this this is another way so if you can directly assign the data to the variables like this or first you create
Speaker A
a variables and then can assign the data so this is a declaration this is called assignment in the first approach we have seen that declaration then assignment here we declared three variables by separating comma and you don't need to write like Ina in B and C
Speaker A
multiple times again so you can simply write one single line to create all the variables then you can assign the data this is one more approach now suppose uh if they are belongs to and this is applicable only if these variables are
Speaker A
belongs to same data type just hold on I'll come to that part okay so if these variables are belongs to same data type then only the syntax is possible suppose a is equal to int B is equal to for C is a string then this
Speaker A
syntax is not possible okay because we specifying the data type only one time then we can add multiple variables so obviously all the variables are belongs to same data type okay now there is another approach see this approach
Speaker A
three in this I will Define in a = 100 comma B = 200 comma c = 300 and this is another approach so in this we Define variable we Define data type only ones and along with the variable we also
Speaker A
assign some data so a equal to 100 comma Bal to 200 comma C = to 300 so we can have any number of variables like this this is also correct notation so this is another approach but if you look at this
Speaker A
second approach and third approach are possible only if these variables are belongs to same data type okay same data type then only it is possible otherwise not suppose if these variables are related to different data types like one is
Speaker A
string another one is float another one is integer then go with the first approach okay so approach three is for if all the variables are belongs to same data type okay so this approach two is applicable only if all the variables are
Speaker A
belongs to same data type same thing for third approach also third approach is also applicable if all the variables are belongs to same data type and if you have a different data types of data then go with the first approach here this is
Speaker A
integer this is a float this is a string like this you can Define different data types so if you have different data types then you can go with if all the variables variables belongs to different data types okay this approach one we have to
Speaker A
follow if variables are belongs to different data types and approach two and approach three is applicable if the variables are belongs to same data type because we specify all the variables with one single data type so ABC are
Speaker A
integers here also ABC are integers so this is also possible so these are the three different approaches which we have to create a variables now I want to get the values from the variables so here I have defined three variables a b c and they
Speaker A
have some data now I want to print the values of a b and c so how can we get the data from a b c if you want to extract the value from the variable you can write system. out. print simply you
Speaker A
can say a variable name so that will print value of a and then I can say here B so this will print value of B then it will print value of C so I can directly specify the variables inside
Speaker A
the print Ln and I execute this this will print the values of a b c so the value of a is 100 and value of B is 200 the value of C is 300 okay now if I look at this output
Speaker A
here you cannot recognize whether a value is 100 or B value is 200 or C value is 300 exactly we don't know what is the value of of 100 what is the value of 200 and 300 right so you can write more meaningful
Speaker A
message in the print L statement so for example here I'm printing just only 100 but I don't know whether this 100 is belongs to a b or c so I can write some meaningful message here in the double
Speaker A
quotations you can write the value of a is okay this whatever you put in the double quotes it is exactly printed in the console window after that this is a variable right you need to do something called concatenation like this
Speaker A
concatenation okay so the value of let me finish I will show you all the combinations once I finish then you can ask the questions okay just concentrate what I'm explaining here I will show you different things let me first finish and
Speaker A
then you can ask the questions okay so system out pint Ln so I can write some meaningful message like this so so the value of a is colon and a so these two are two separate entities right so this is a string which we are
Speaker A
directly printing okay for example I remove this a now what will happen whatever you put in the double ports it is exactly printed in the console window see here the value of a is that's it but here I want to print the value so how
Speaker A
can we do this you have to do something called concatenation plus is a concatenation operator so when I say plus a then what happens whatever the value we have assigned to the a that will be printed as it is in the console window along
Speaker A
with the string so when I execute now we can see this is more meaningful message the value of a is 100 right so like this we can simply write for B also we can say the value of the value of B
Speaker A
is and concatenated with b and same thing here can say the value of the value of C is and here you can say concatenation so we can also customize this message more meaningful manner right so now we can see it is
Speaker A
more meaningful the value of a is 100 value of B is 200 value of C is 300 okay so like this we can extract the values from the variables now here if I look at this I have printed the values
Speaker A
in the different statements when I print a value I have written one print statement when I print B value I have written another statement when I print C value I have written another statement so instead of writing multiple
Speaker A
statements can I write one single print statement which will print all the values of a b and c can we print one single statement by using one single print statement can we print the values of all the variables
Speaker A
you can still print it but we need to slightly customize the statement let me show you how we canver this system pint here you cannot directly say a comma B comma C this is not allowed comma operator not allowed in Java okay but I
Speaker A
want to print all three values with single line so then how can we do this can we use concatenation like this a first value we will print then concatenated by B then concatenated by C is it possible when I use concatenation
Speaker A
then what will happen now because a c are the integers right so when I use plus operator they will do addition instead of printing the 100 200 3 just it is added just 600 it is performing addition operation so we are not getting
Speaker A
exact values so so how can we print all the values in one single line okay so if you want to print this we can simply customize it so how can we customize first you print a value okay and then concatenate with some space
Speaker A
like this and then again one more concatenation after printing this B value concatenate with some space again then again concatenation means we have to give some space between each and every variable and this space is just like a string okay now if I print this r
Speaker A
as Java application now we can see all three values in one single line okay because if I don't use this string between these numbers then what will happen it will perform addition operation all three numbers it is added
Speaker A
so we are not getting exact value so if you add this space in between this VAR variables this is considered as a string even though if you don't have anything in the double quotations it is empty or space so when you concatenate with the
Speaker A
space then first it is printed a value then it is giving some space after that printed B value then given some more space then printer C value so like this we can print all variables values in single line so this is also right okay
Speaker A
so this is how we can simply work with the variables you can simply work with the variables so these are the different approaches so if you have a different variables with a different type of data you can go with the first approach and
Speaker A
if you have variables belongs to same data type then you can go with approach one or approach two anything is fine and we can extract the data from the variable just by using variable name in The Print L statements
Speaker A
okay so is this clear everyone please put in the chat box confirm in the chat box is it clear so far about variables and don't go beyond this so whatever so far I have covered is this clear so we have seen all the
Speaker A
combinations the last syntax is simple I just printed a variable a okay and then this is called concatenation operator so concatenation means in the next example you will understand more about this plus operator and basically plus is a
Speaker A
concatenation operator concatenation means what it will join multiple things so here a b c three different variables are there right so these different variables we have joined with the space here it is one join here it is another
Speaker A
joining okay we combined three variables but still we want to get a values from it so I just put concatenation with the space in the next example you will understand more about this okay all right so this is all about variables so
Speaker A
what is variable so far what we understood variable is a container which can hold some data and to representing the data we have to create variables and the values of the variables always varies that's the reason we call them as
Speaker A
a variables okay and when you create a variable you must specify the data type without data type we cannot create a variable and how to decide the data type based on the data so what type of data we are storing into variable accordingly
Speaker A
we have to choose the right data type okay so now we have discussed more about variables now let us try to discuss about data types so guys if you have any questions or any queries let us discuss at the end
Speaker A
of the session okay so in yesterday's class if you have any issues at the installations and everything don't discuss now let us Focus completely on your session first so don't distract your mind unnecessarily okay so first listen things at the end of the session
Speaker A
you can share your screen and you can discuss all your queries okay so don't think about all those things let us Focus first of all right so we have done with the variables now let us move on to the data
Speaker A
types okay your focus will be lost if you're thinking about something else you're asking something else means you are not focusing here so please focus and if you have any queries we will discuss at the end of the session we have a separate
Speaker A
time for that so what is data type what is data at the beginning I told you data type is nothing but what it represents the type of data very simple definition so data type is always represent the type of
Speaker A
data right so represents type of data so whenever you store some data in a variable we have to specify the data type so that we have understood so far so whenever you specify some data or whenever you want
Speaker A
to store some data in a variable you have to specify the data type but what are the data types are available in Java and which data type we have to choose while creating the variables okay in Java we have so many
Speaker A
data types are there mainly we can divide it into two categories two categories of data types one is called primitive data types this is a categorization primitive data types second category is non primitive non primitive and these are
Speaker A
also called derived data types also called collections okay so these are the two different types categorization represents uh type of data so primitive data ypes nonprimitive data types primitive data types non-primitive data types non-primitive is also called as derived data types or
Speaker A
collections so I will list out whatever primitive whatever non-primitive and non- primitive these collections we will separately discuss in another sessions which is very very huge concept so today let us Focus only on primitive data types okay now in the primitive data
Speaker A
types what are all different types are available and we can again categories to four different types to represent the numbers we have four data types one is called bite all are lowercase characters bite short int long so these four data types
Speaker A
we will use to represent number without decimal okay by short int long so these four data types we can use one of the data type to represent a number without having decimal if you have a number with doesn't have any decimal then you can
Speaker A
use either bite short int long four data types are available to represent the numbers now suppose if you have a decimal number to represent a decimal number we have two data types one is float second one is double float and
Speaker A
double these two data types we can use to represent decimal numbers decimal number if you have a decimal number we choose either float or double but again you will have a question which one we have to choose again bite short in Long there are four
Speaker A
data types are there to representing the number which one we have to choose that depends on size of the data I will also discuss that so representing the numbers without a decimal we have four data types bite short int long and to
Speaker A
representing the decimal number we have a two data types either float or double and to represent a single character we have one data type called CAP so this particular data type will represent Single Character that we should keep in
Speaker A
the single quotations Single Character is always put inside the single quotations represent single code we have to use character data type now there is another data type called Boolean Boolean and this particular data type we can use to
Speaker A
store either true or false Boolean value it is accepted that variable can hold only either true or False only one value we cannot store any other type of data in a Bo variable so these are the different primitive data types white
Speaker A
short int long is for number without a decimal float and double is for decimal number car is for representing a single character that we should keep inside the double quotations and Boolean is another data type which we can use is
Speaker A
for uh true or false we can keep either true or false in the Boolean variable these are all primitive data types which we are common commonly used in our programming now nonprimitive derived or collections here we have string which is
Speaker A
very popularly used array list hash map hash set there are many more are there so there are so many collections are there so many derived data types etc etc so these are all comes under non primitive derived Collections and if you look at this
Speaker A
these are started with uppercase characters every type is started with uppercase character whereas primitive types are started with all lowercase characters you need to just recognize easily okay so string comes under non-primitive type it is not a primitive
Speaker A
type but what is the difference what is the difference between primitive what is the difference between primitive and non-primitive and when we have to use primitive where we have to use non-primitive primitive data types we can use to store
Speaker A
single data at a time okay for example just try to understand this I have different students I have let's say so many students are studying in a class now to representing the student ID I can create one variable like this right in
Speaker A
student ID equal to let's say 101 so here what I've have done I created only one single variable which can hold only one single value at a time so whenever you create a variable that can hold only single value at a time so after you
Speaker A
change for example St ID you become one2 then what happens 101 is replaced with one2 still it is having only one value at a time that means all primitive data types we can store only one value at a
Speaker A
time in a variable okay that variable can hold only one value at a time all primitive types but sometimes we will have some requirement like we have to store multiple values into single variable multiple data into single variable that means single variable can
Speaker A
hold different sets of data different type of data for example let us say I have 100 students are studying in my class and to store a every student ID how many variables you have to create suppose let's say 100 students are
Speaker A
studying in a class for each student is having ID student ID so I want to I want to store 100 student IDs so how many variables we have to create normally 100 variables are required right to store 100 IDs we have to create 100 variables
Speaker A
when you create 100 variables in a program it is very very difficult to manage right you cannot refer the variables very difficult so instead of creating 100 variables if I store 100 IDs into one single variable it is very
Speaker A
easy to manage in that case we use non-primitive for example array list if you look at array list if you create a variable with array list we can store multiple values in one single variable even same array also comes under non print if I create
Speaker A
an array variable so for example let's say in a okay is equal to new in of 100 if I Define like this this is called array in the coming sessions I will explain in detail Just For Now understand so this is it is not a normal
Speaker A
variable now a is a array variable array means what it can hold multiple values how many values it can hold depends upon the size we specified here this is called size when I say 100 in a I can
Speaker A
store 100 values I can store 100 values in a so as soon as you created a variable like this internally what happens it will create 100 memory locations like this the variable name is called a and 100 we specified the size
Speaker A
so here it will start from zero 0 1 2 3 4 like this and these are the memory locations in these locations we can maintain the data let's say here one 1 one2 one3 these are all student IDs so
Speaker A
to represent the data what we can do by using index we can access suppose when I say A of two that is representing this one this data when I say A of one then it is representing this one when I say A
Speaker A
of zero then it is representing first one so with single variable we will able to manage all the data the means multiples sets of data we can manage with single variable that means primitive data types allowed single value at a time in a variable at at a
Speaker A
time only one single value is allowed in a variable non primitive we can store multiple values in a variable for example let's take the string how to create a string variable string is equal to let's say welcome I have written like
Speaker A
this semicolon see this statement string s equal to welcome s is what string type so we can store multiple values see these are all multiple characters are not w e l C O M there are multiple characters so multiple characters we can
Speaker A
store which is called as a string but if you want to store Single Character then what you will do you will use primitive datae car c equal to let say a single quotation so if it is a primitive it can
Speaker A
hold only one single value if it is a non-primitive it can hold multiple values that is a major difference between primitive data types and non primitive data types so for now just understand only this much in the coming
Speaker A
sessions I will elaborate more about non-primitive data types we will discuss each and every non-primitive data type in detail okay there are multiple sessions we take so let us focus on primitive data types okay so bite short in Long comes
Speaker A
under uh we can use them to represent numbers without having decimal float and double is for decimal number car is for single character buan is for true and false if you want to store a string we can use non-primitive type string is a
Speaker A
non-primitive Tyle okay now so let us see one example how can we use this primitive data types and one more thing if you look at this first one to representing the number without having decimal we have a four
Speaker A
types bite short int long but again which one we will choose choose suppose I want to store 100 which one is suitable bite short int or long or suppose if you have a very big number let's say I have a 10 digits
Speaker A
number then which one is suitable so you have to choose the right type based upon the data you have based upon the size of data okay but how we will know that which one we have to select bite short
Speaker A
int long so Java is provided that information so I will share some small table here and accordingly we can easily find out so which data type is having what is the size and how much size of data the particular data type is allowed
Speaker A
okay so let me just put one small table here so that you can understand okay now just look at this this is a table and this is given by Java guys we haven't designed anything here new so first let us the
Speaker A
bite so these four bite short int long these four are for numeric data types we can use it for storing numbers without having decimals right so when you create a variable with bite right so we can store the value
Speaker A
which is between inside this range minus 128 to 128 even negative values also we can store in the variables not only positive values we can also store negative number in a variable for example you can create in a equal to 100
Speaker A
you can store which is a positive number and you can also store a equal to minus 100 you can also store negative number okay positive as well as negative numbers also allowed so if you create a variable as a bite we can store numbers
Speaker A
between this particular range between minus 128 to 127 is the range and if the number is uh Beyond this range you cannot store so let's say this is a graph zero 1 2 3 4 here + 128 here -1 -2 - 3 here Min - 128 so
Speaker A
between this range whatever numbers are comes under all these numbers we can store in a bite variable which is very smaller size actually B is a starting size so when you create a variable with the bite so let's say bite
Speaker A
a then I can store in a between this minus 128 to plus 128 between this range whatever numbers comes we can store those numbers in a variable okay if you remember this range you can you will know exactly which data
Speaker A
type you have to use bite suppose if you have a number more than this little bigger then you can go with the short data type so short will allow the numbers between this range minus 32 768 to 32767 so between this range whatever
Speaker A
numbers comes all these numbers we can store in the short data type and again if your number is exceeded this number let's say you have 33700 something like this 33700 this is exceeded this number so now is it
Speaker A
possible to store in the short data type no okay because this number is higher than this last number right so it is exceeded the range so we need to go to to higher levels then we can go to
Speaker A
integer data type so when you create a variable as integer data type we can store very big number so between this Min - 2147 483 6482 2147 483 647 so this is a maximum number so between this range all the numbers we
Speaker A
can store in integer variables and if the number is even though very bigger then long so you can see this is the maximum range so most of the times we don't go more than this number this is a maximum
Speaker A
number which is allowed in the numbers so long long means if you create any variable with a long data type I can store any number between this particular range okay for example I have created a variable with a long data
Speaker A
let's say l some X okay so now I have stored in X just only 100 will it work or not will it work or not I just created a variable long X and then I have stored 100 into X is it valid or not will it
Speaker A
work or not yes obviously it will work because what is the range of long here between these two this the 100 fall right but what is the Des advantages in this if you do like this what will be the
Speaker A
problem yes unnecessarily memory will be wasted why because as soon as you say long data type for X their huge memory will be allocated because the range is very high right the huge memory is allocated for X but you are storing very
Speaker A
small number so you are just using only this much of space so rest of the space will be what wasted okay so that is the reason based on the size of data you can rightly choose particular data type so that will
Speaker A
not waste on time okay suppose I have taken bite some X now I'm trying to store some number like this is it possible or not I've taken bite variable X and then I'm storing a bigger number it is not betweenus 128 to 127 more than
Speaker A
higher right more than is exceeded 127 so this is not not possible we trying to store higher value in the lowest space not possible okay but you can store lowest value in higher space even though the memories got wasted still you can store
Speaker A
lowest value in higher space okay so most of the time which one is moderate here is integer so whenever you are working with the integer data types most of the times we try to prefer in and if if your numbers is more than
Speaker A
integer more than this then you obviously go for long data type but very rare case you use that one okay so this is most uh moderate data type in to representing the numbers so guys now you understood so why they have provided
Speaker A
four data types for to representing the numbers based on the size of the data we have to choose the right data type and same thing for double also like decimals these two data types are available for storing decimal numbers float and double
Speaker A
so float is nothing but what it is allowed four bytes of size means what can store fractional numbers means fractional numbers in the sense decimal numbers sufficient for storing seven decimal digits suppose if you have a number like this so after decimal Max
Speaker A
seven digits are allowed if you create variable with the flow to data type in that number in that variable you can store Max seven decimals Max seven decimals are allowed if you create a float variable and before decimal you can have any number
Speaker A
but after decimal Max seven decimal numbers are allowed and if you have more number of values then you can go with a double eight bytes almost double that means after decimal up to 15 decimal numbers are allowed after decimal 15 numbers are
Speaker A
allowed okay that is a difference between float and double so most of the times we will try to use double this is the moderate data type and then we have a Boolean so this is only one datae which can hold only one bit we can store
Speaker A
either true or false nothing else and car allow two bytes that means only one single character we can store if we create any variable with the c type in that variable we can store only one single character or one single
Speaker A
letter okay so these are all primitive data types so now let us see one example practical demo how to use these data types how to create a variables with a different data types and how to access the data from those variables let me
Speaker A
show you one example so far everything is clear please confirm in the chat box everyone so what is variable why we need to create a variables what is the data type why we need data types and how many
Speaker A
types of data types are available in Java and what is the difference between primitive and non-primitive data types so these are all most important and very basic and fundamentals now let us move on to the next example data types so now
Speaker A
I'm going to create a new class to demonstrate data types let's create a new class and my class name is you can give any name to the class no problem but don't give any spaces numbers and also and simply say data types
Speaker A
demo I'm taking main method also click on finish yeah now it is created a new class which contains main method this is a simple comment I can just all right now let us see a small demo on data
Speaker A
types first let us start with the numeric data types numeric data so here I'm just keeping the comment so that you can easily understand the code later okay numeric data types so I will Define two variables can see here in a
Speaker A
100 b equal to 200 can we Define the variable like this is it valid syntax or not is it valid syntax or not yes both are same data types right if a and b are both are same data types
Speaker A
you can create number of variables in one single line right so now I just want to print the value of a system print and I just print value of a okay and also I'll write in simple meaningful message I can say the value
Speaker A
of a is and then concatenation and same thing I'll try to print the value of B so here I'm printing value of B now I want to perform sum of A and B I want to add these two
Speaker A
numbers I want to add these two numbers simply what you can say a plus b right so let's try to execute so now we got value of a is 100 the value of B is B and then 200 the total is 100
Speaker A
300 now I want to write more meaningful message here for the third statement so what I can do is I can say the sum of A and B is okay now I'm keeping concatenation of WR just observe this I just written
Speaker A
more meaningful message just like how I have done in the previous two statements concatenation here I just printed a value of a here I'm printing value of B and here I'm printing the value of a plus b right concatenation now if I just
Speaker A
observe the output see now how it has got printed so this is not our expectation right so we have to get 300 but instead is just printed the value of a and b directly so what exactly Happening Here
Speaker A
is first it is printed as it is in the console window and then concatenated with the a 100 is got printed then immediately concatenated with the V because why is got printed like this for example exle if you do like this
Speaker A
directly if you print a plus b without having this message so I'm just removing this message I can simply say a plus b right so in this particular case you will get a 300 but when you use same a plus b
Speaker A
with this concatenation you are not getting the right value what is happening here is before printing this a plus b you're concatenating with string actually so when you're concatenating with this with a string what will happen is here it is
Speaker A
confused there are two plus operators are there so whether is it want do you want to do addition or do you want to do concatenation what exactly you want to do so because when I use two plus operators one after another it is
Speaker A
basically confusing so it is directly as it is printed a value and B value but still I want to get a plus b the addition of two number I want to get so simply you can put that expression in
Speaker A
the bracket okay so now what happens first this expression will be executed a plus b will be executed which is 300 then it is concatenated with this so now you will get the right Val okay so now we can see the right
Speaker A
Val so this is how we can simply use numeric data types so now let us see decimal number so in the decimal okay so again in the integer we have different types like short we have short and before short do we have any
Speaker A
other numeric types let us say I have bite short in long so we have seen integer now let us see bite short and long bite there a bite bite b equal to so what is the range of bite dat type
Speaker A
minus 128 to 127 right so let's say 25 and Stor b b equal to B is already used this variable A and B already used so we have to give some different variable here same variable name you cannot refer multiple
Speaker A
times because B is already created with integer so same variable name you cannot use so you have to use some different name let's say b y by Y is a variable name and now I want to just print this
Speaker A
value can say B1 so this is bite and similarly short if you want to use short sh equal to in the short what is the number I can store what is the maximum and minimum range this is maximum range
Speaker A
3276 7 32767 okay so that is a value is a maximum range between the strange you can use anything let's say 35 uh 35 you can just use 35 35 can we store 35 35 yes so this is a short then
Speaker A
you can print so before using the data type you need to know the range actually so if you know the range exactly you will know exactly which data type is AP for your data and then bite short and
Speaker A
what is the next one long long is for very big value I can say long L equal to can put very long data type so I can say very larger number semicolon and then trying to print value called L okay now
Speaker A
just observe this when I use integer or when I use bite when I use short there is no syntax error but when you create a long variable when you create a variable with a long data type after specifying
Speaker A
some data here it is giving some error the literal of type int is out of range okay so whenever you specify the value in the long variable you have to write something called literal means what at the end of
Speaker A
the value we can simply say lower case l or upper case L this is mandatory okay not for every data type especially for long and Float so for these two data types we have to add literal which is representing with l
Speaker A
okay it can be lower case like this or it can be upper case okay now I have assigned some you can put any data any size like say 1 2 3 4 5 6 7 8 n maximum number so now I'm printing the longw
Speaker A
just observe this what will happen so when I run this see 125 is a b value so 125 is got printed then 3535 is got printed which is short data type and now when you come to the long this this is actual value
Speaker A
actual value is are exactly it is printed this L will not print because this is a symbol which is representing a literal okay and especially for long and Float so these two particular data types we have to specify literal okay literal
Speaker A
in the sense because it is a long data type you have to say l if it is a flow data type then you have to say f that's called literal okay so these are all numeric data types without decimals we
Speaker A
can use either bite short long or in right now let us see the decimal numbers decimal numers and in the decimal we have a two data types decimal numbers we have a two datas float double float and double
Speaker A
okay float is a smaller double is a bigger number float means it is allowed seven decimals double is allowed 15 decimal okay now first let us start with the float float let's create one variable called item price let's say 15
Speaker A
do five and just created one variable now just observe when I assign some data to the variable it is giving a error what it is expecting it is expecting cannot convert from double to float so this is actually decimal number
Speaker A
we are trying to store in a float variable so what we need to do is we have to specify the literal it can be lower case f or it can be upper case f anything is fine okay and then you can
Speaker A
print the value can directly print item underscore price okay now we can see 15.5 I have given and same thing is got printed okay now if you have more numbers like more decimal numbers okay then you can use double
Speaker A
double as a DBL equal to and I can say bigger decimal number like this and then you can here there is no literal required you can directly print it as a DBL so for double we don't need any literal we can directly write so
Speaker A
this is mostly used double run as Java application so now we got the value exactly how much value we have stored we got it so the literals we have to add only for two data types one is for long
Speaker A
so here literal is needed and also for flow data type also we need to add literal okay here f is f or small F anything is fine but here for long use either capital l or small L at the end of the value you have to
Speaker A
specify this so these two are the decimal numbers and now let us see the character so car is another data type so to representing the Single Character we use car data type you can say car Cal C is already used so I'm just giving
Speaker A
some different name let's say grade and single characters we always keep inside the single quotations Single Character always represent within the single quotations so multiple characters if you want to store then what you will do you want to store multiple characters what
Speaker A
you will do we go with string okay so string can store multiple characters right string non- primitive type so I can just print grade so this is simple character data type so whatever value we have asend here we just printed only one single
Speaker A
character is allowed suppose if you want to store multiple characters then we have to use string string suppose name equal to let's say John so multiple characters whenever you specify keep inside the double quotations okay that is representing the string
Speaker A
so strings will represent with the double quotations string is a nonprimitive type okay then you can see the difference also you can see normal primitive types appear in the different color and string is appear in the different color in the string s is a
Speaker A
uppercase character and rest of all data types me dat is start with the lower case characters now we can directly print name see name so if you have a single character keep in the single quotation and use cash data type if you have a multiple
Speaker A
characters then keep inside the double quotations and use string data type so now we got a JW okay now uh in the string there are multiple combinations which we have uh in the next example uh okay so let me show you
Speaker A
here itself so in the multiple combination let me write something here you guys can tell me whether this correct way of writing or not so we have seen C data type and also we have seen string data type so we understood this
Speaker A
car means Single Character we should keep inside the single quotation string means we should keep inside the double quotations multiple characters right now observe this in car variable CH equal to in the single quotations I'm writing ABC is it valid or
Speaker A
not is the statement valid or not car CH equal to ABC this is invalid this is invalid why it is invalid because we are sto trying to store multiple characters and we put in the single quotation that itself is a mistake and
Speaker A
type is what cap so this is invalid we cannot okay suppose if you write like this string CH equal to ABC is it valid or not string CH equal to ABC valid or not it is still invalid why even though
Speaker A
this variabl can hold string but we use single quotations right if you represent multiple characters they should be in the double quotations so so single quotation is not allowed so this is also invalid statement this is also invalid okay now observe this one
Speaker A
string CH equal to a is it valid or not string ch ch is a string variable but I'm trying to store a character so this is also invalid why because we put in the single quotations single quotations is always representing
Speaker A
the character so this is also invalid now observe this string CH equal to double quotes a is it valid or not yes this is valid because why we Define the variable as a string and we use double quotations within the double a you can
Speaker A
have a single character or multiple character doesn't matter it will treat it as a string okay as soon as you put string type and double quotations that is over you can put either Single Character or multiple characters doesn't
Speaker A
matter so now string CH contains one single character so this is valid statement so now you understood the difference between character and string character means always single character with single quotations string means always having double quotations but it can have single or multiple
Speaker A
characters okay that is a difference okay now let us see Boolean type Boolean Boolean means what it can accept only true or false let's say Boolean uh a bull or you can say BL some variable name equal to
Speaker A
true true or False only two values are accept so I can just print BL right so now if I just observe so this will print BL value which is true which is true now when I make it as
Speaker A
a false when I make it as a false so then it will print false so only true or false allowed so Boolean variable allows only true or false we can't store anything else and moreover we should not put the double
Speaker A
quotations remember this okay now let me just give you some example you guys can tell me whether valid or not here I'm creating a Boolean value Boolean so let me just commment this so Boolean BL equal to True is it valid or
Speaker A
not it is not valid why because we put this true in the double quotations so as soon as you put this in the double quotations that will be treated as what string so then you should specify the data type as
Speaker A
a string then only allowed okay so this is not valid so this is not valid now I'll write something like this Boolean B equal to double quotation false is it valid or not this is also not valid not Val because we put in the
Speaker A
double quotations as soon as you put that in the double quotations which is treated as a string that we cannot store in the Boolean variable so this is clear now observe this string BL equal to string BL equal to
Speaker A
true is it valid or not string BL equal to this is also not valid because this is a Boolean data because we we do not put in the double quotations but the variable is what string right so this is also not valid
Speaker A
this is also not valid right so string BL equal to true or false not valid now string BL equal to true is it valid or not string BL equal to True valid or not obviously it is valid because we put
Speaker A
in the double quotations as soon as you put in the double quotations that will be treated as a string so even data type is also string so allowed this is valid okay so in the Boolean variable I can store only true or
Speaker A
false we should not put double quotations this is a synx okay so this is all about Boolean data type so we have discussed all these data types bite short in Long float double care and then Boolean so now is this clear everyone so
Speaker A
how to work with the primitive data types string is also very huge Concept in the coming sessions uh we will discuss more about strings so in the upcoming sessions you will understand exactly where we will use all these data types in almost in
Speaker A
every programming examples in every solution we will use all these data types okay so we are just discussing the concept here so once you understand the concept you will exactly know where exactly we apply this so what is the
Speaker A
main purpose of creating the variables what is the purpose of creating the variables why we need to create a variables yes to store the data you want to store some data we have to create a variables and what is the use of data
Speaker A
types why we need to use data types because before storing the data in a variable we have to specify the data type otherwise Java is not allowed so data types must be specified before creating the variables so once
Speaker A
you have data in the variables we can operate the data by using the data by using the variables we can perform various types of operations and then we have to know operators so there are different type of operators of in Java in the next class I
Speaker A
will discuss more about operators then you will exactly know where exactly we use these data types so whatever topics we are discussing here concept wise everything we will use in the applications because slowly you will understand itself okay
Speaker A
so once you start giving more number of examples you will understand exactly where you will use all these Concepts so Boolean is basically we use to store the status for example uh let us say uh simple example I will
Speaker A
give you you can understand where exactly we use Boolean value so most of the times to maintain the flag kind of thing status kind of thing we will use a Boolean data type for example let's say I have some numbers in my array okay
Speaker A
let's say I have different numbers here let's say 1 2 3 4 five now I want to find this particular number three is present in this array or not okay I want to check this particular number is present in this array or not so then
Speaker A
what you will do first you will compare with the first number not matched so initially you will take one flag let's say this is a Boolean variable let's say false initially it is a false representing not found okay so let's say
Speaker A
three matching with one matched or not no not matching then we will compare with the two not matching now comparing with the three now here it is matched as soon as it is matched then we'll make this flag value is equal to
Speaker A
true so here we will maintain this Boolean variable to representing some status okay some stat suppose I'm doing some operation okay it is in progress so before starting this operation okay the status will be false and after the
Speaker A
completion of this operation I'll make the status is true so that is representing whether my process is started or not or completed or not so to represent that we can use a Boolean variable so like this there are many
Speaker A
scenarios we will try to use this Boolean variable you will understand definitely you will understand this I will show you so many example in coming sessions okay so where we can use bite data type so whenever you want to store number
Speaker A
which is between minus 127 and 128 you can use bite so there is no rule like you have to use only bite here you have to use only integer here you have to use only float here not like that it is up to you
Speaker A
depends on your own requirement you can create any number of variables any data type you can use so there is no specific reason to use bite data type okay if you have small number you can use by data type no
Speaker A
problem and if you have little bit bigger number then you can go with the shorter or little more bigger then you can go with the IND or more larger number then you can go with the long it depends upon the data size you have
Speaker A
accordingly you have to choose the right data type so memory allocation uh is not that much important because we already discussed about the ranges right so this is a range actually so I put some table right so here can
Speaker A
just remember this table not that much important just understand every data type is having some range or some size so whenever you create a one byte right so it is allocat some memory in that memory can store the number between this
Speaker A
range so when I say two bytes of memories allocated for short VAR and you can store this much of data similarly when I create an integer variable four bytes of memory is allocated and this much of number you
Speaker A
can store so for every data type there is a size this much of size the memory is allocated for that particular variable okay literal is a simple or a character which we need to add after the data so for example if I look at this uh
Speaker A
especially for float and long right so you can see this is called literal so whatever the character we are adding at the end of the value normally we call as a literal that is just a terminology Java prospective okay and for the float
Speaker A
also we use something called EF that is a literal it can be lower case or it can be upper case so this is designed by Java itself okay so why they have put this literal for only float and for long we don't
Speaker A
know exact reason for so why they have put like this so we just following as per Java uh instructions this is just a terminology guys so don't fix the meaning for this literal is just a terminology we use
Speaker A
this literal word in many places in multiple prospectives here we can just call it as a literal that's it so string literal is different okay so we'll discuss that literal is the total meaning is totally different so the same
Speaker A
meaning should not apply in everywhere so here the literal means just a one character which we need to add after the value and the same literal keyword we will use in the different places for different meanings so string letter is
Speaker A
totally different than this one so we'll again discuss that later not related to this topic okay so everyone is understood what is variable what is a data type and all those things okay now at last I will show you
Speaker A
small thing here and try to understand very very important interior perspective which is most important okay let's try to understand this so if you take any programming language okay it can be either uh statically programming language or dynamically programming language just a
Speaker A
moment don't write anything El okay so before discussing that I have one question difference between variable and constant variable can hold the data okay and suppose in future if you don't want to change the data so normally when you
Speaker A
create a variable see in a equal to 100 so a is a variable which can hold the data right suppose in future if you don't want to change the data so by default the value of the variable can
Speaker A
always change so later if you want to change a value 200 you can make it as a 200 after that if you want to make it 300 you can make it happen like this every time the value of the variable can
Speaker A
always change that is a default Behavior okay but sometimes in your programming you don't want to change the value every time so whatever value initially you have assigned that is always fixed value you don't want to change that value okay in those cases
Speaker A
what you will do is you will additionally add one keyword here like final or in some other programming languages you will have one more keyword called constant like this so when you have this keyword in front of the data
Speaker A
data type what will happen this value we cannot change in future so that variable is not allowed to change the value in future in that case we can call it as a constant variable okay constant variable so if
Speaker A
the values keeps changing the for the variable that is just a normal variable and if you're are not able to change the value of the variable that is called constant variable okay now you understood what is variable and constant is is a keyword
Speaker A
actually that is belongs to the variable if the values keeps changing it's just normal variable default Behavior but if you're not changing this value I don't want to allow to change this value in future I can make this variable as a
Speaker A
constant in Java we can use something called final so then this variable is a constant variable means we cannot change the value at any point of so that is a meaning okay so shall we proceed in the last simple another two minutes simple
Speaker A
concept which we have very important for inter perspective so let us try to understand any other questions we will discuss later right so in programming if you take Java or python or C whatever programming language you take okay and
Speaker A
there are uh two kinds of programming languages statically typed programming language dynamically typed programming language observe very carefully I'll tell you what it is Java is statically typed programming language Java is a statically typed programming language python is a
Speaker A
dynamically typed programming language python is a dynamically typed programming language so what is this we need to First understand what is statically typed what is dynamically typed this topic is more related to variables and data types so that's the
Speaker A
reason I'm just covering this part and interal prospective most important Java is a statically typed programming language python is a dynamically typed programming language so let's try to understand what it is with some examples I'll try to uh
Speaker A
explained let us say in X = to 100 I have created one integer variable X and I have sto 100 into X okay now X is a integer type of variable so that I can store number right now in X I'll try to change
Speaker A
the value of x initially 100 now I want to become welcome is it possible or not in Java as per your understanding just tell me is it possible or not in Java X is integer 100 then I'm saying x
Speaker A
equal to welcome suppose x equal to 200 is possible or not this is possible or not it is possible why because here is 100 and here also 200 both are numbers so the value we can always change but
Speaker A
instead of 200 when you put welcome here this is not allowed in Java it is not allowed why it is not allowed because X is already created with the integer type of data integer type of data type so integer data type
Speaker A
we already applied for this x variable so we cannot change the data type we can change the value but we cannot change the data type initially it is integer now as soon as you put the value in the
Speaker A
double quotation it is a string so it is not allowed okay it is not allowed this is not allowed but in Python it is allowed in Python it is allowed it is python it is allowed so why it is allowed because in Python we
Speaker A
are not going to specify any data types in Python data types already there but we know need to specify the data types explicitly that means you can directly write x equal to 100 so whenever you say x equal to 100 x will be automatically
Speaker A
treated as an integer X will automatically treated as a integer as per python I'm talking about okay you don't need to write a data type explicitly simply can say x equal to 100 so X will be treated as
Speaker A
integer now immediately when you say x equal to welcome now what happens now X will be treated as a string X will be as a string so that it can also hold string value so this is possible in Python so
Speaker A
that is the reason it is dynamically typed programming language in Java it is statically typed programming language so once you create a variable with one data type you cannot store any other data type in the same variable this is not allowed in Java but
Speaker A
in Python it is allowed why because you don't need to explicitly specify the data type that is one thing and whenever you change the value or data type anything obviously it will be converted so initially here x is integer here x is
Speaker A
a string okay so this is dynamically typed programming language this is one feature dynamically programming language uh statically programming language so in statically typed programming language whatever data type is specific the variable same data we have to add you
Speaker A
can change the value but the same data value we have to add but in Python we can add any type of data so in Java we have to specify the data type but in Python we don't need to specify the data
Speaker A
type so based on the data which we have added accordingly the data type is automatically assigned to the variable so here if you say string here so now X is a string variable okay so this is a feature
Speaker A
actually so the python is a dynamically typed programming language Java is a statically typed programming language so guys you understood the difference statically typed programming language dynamically typed programming language okay just remember this point okay so in the next class we will
Speaker A
discuss some more things so we will stop it here so after one or two sessions then I will start giving assignments so till that time so you can just practice class demos whatever I have given and you can try your own also so based on
Speaker A
our examples you can just try your own examples and uh once you complete uh operations uh conditional statement looping statements and everything then we'll start giving some assignments because before starting assignment you need to know some basic concepts you
Speaker A
have to be clear more about them so then you can start creating are doing the assments okay so just practice this class examples for today's session tomorrow and today and uh tomorrow we'll continue that okay so I'll stop
Speaker A
here and we'll continue tomorrow's session
Topics:Java variablesJava data typesJava programming basicsSeleniumSDETQA automationJava int typeJava String typeJava float typeEclipse IDE











