Session 2- Working with Java Variables and Data Types | Java & Selenium
Estimated read time: 1:20
Learn to use AI like a Pro
Get the latest AI workflows to boost your productivity and business performance, delivered weekly by expert consultants. Enjoy step-by-step guides, weekly Q&A sessions, and full access to our AI workflow archive.
Summary
In this video, the instructor from SDET-QA continues teaching fundamental concepts of Java programming, with a focus on variables and data types. Following the introduction classes where Java and Eclipse setup were covered, the session dives into understanding Java variables – containers for storing data, and how they differ from constants. The importance and application of data types, categorization into primitive and non-primitive types, and the correct usage of these data types based on data size and type are explained. Java's strongly typed nature is compared to Python's dynamic typing, enhancing the understanding of variable behavior in different programming environments.
Highlights
Java variables are mutable containers, meaning their values can change over time. 🔄
Constants in Java are variables that are immutable, with values that cannot change after initialization. ❌
Primitive data types in Java include byte, short, int, and long for numbers without decimals; float and double for decimals; char for single characters; and boolean for true/false. 📚
Non-primitive (or derived) data types, like String, Array, etc., can store multiple values and are often more complex. 🌐
Data type choice in Java is important for efficient memory usage and is based on data size and nature. 📐
Java requires explicit data type declaration, unlike Python, which infers types at runtime. This makes Java a statically typed language versus Python's dynamic typing. ⚖️
Key Takeaways
Understanding Java variables as containers for data and their mutable nature. 📦
Difference between variables and constants, and when to use each. 🔄❌
Importance of specifying data types in Java and their categorization into primitive and non-primitive types. 📊
Learning the ranges and appropriateness of different numeric data types (byte, short, int, long) based on data size. 📏
Using literals in Java to specify data types like float and long correctly. 📜
Comparison between Java's static typing and Python's dynamic typing for better programming flexibility and understanding. 🔄➡️
Overview
The session opens with a recap of the previous lesson and moves into the core of understanding how Java variables operate. Variables in Java act as 'containers' to store data that can change throughout program execution. The instructor emphasizes the necessity of specifying data types, which dictate how much space the variable occupies in memory and its data capacity.
Next, the distinction between primitive and non-primitive data types is drawn. Primitive data types, such as int, byte, and char, deal with fundamental pieces of data, whereas non-primitive types like Arrays and Strings hold collections of data. This categorization helps in writing effective and error-free codes by ensuring proper memory allocation based on data needs.
The lesson concludes with a comparative analysis of Java and Python concerning typing systems. Java's static typing requires predefined data type declarations, providing a controlled yet rigid framework, whereas Python's dynamic typing allows more flexibility at the cost of explicit type safety. This discussion underscores the importance of data types in programming, impacting both functionality and resource management.
Chapters
00:00 - 00:25: Introduction & Review of Previous Class The chapter begins with a review of the previous class session where Java programming was introduced. The focus was on installing Java and the Eclipse IDE. The installation process was covered, and a basic program was demonstrated to show how to start creating Java projects.
00:25 - 00:30: Java Basics The chapter introduces the basics of Java programming. It begins with setting up a new Java project, followed by creating a new Java package and a class. Simple Java programs are discussed. The focus then shifts to learning the foundational concepts essential for any programming beginner, including variables, how to create them, and the utilization of different data types.
00:30 - 01:00: Introduction to Variables The chapter titled 'Introduction to Variables' begins by emphasizing the importance of understanding data and variables when starting with Java programming. It introduces variables as containers that hold data, and mentions the necessity of defining them properly. The chapter outlines the intention to teach not only about variables, but also data types, conditional statements, looping statements, arrays, and strings in a progressive manner. The immediate focus, however, is on learning about variables and data types as foundational elements.
01:00 - 01:30: Using Variables - Examples The chapter introduces the concept of variables in programming. It explains that variables are used to store data and are essentially characters or letters that represent data. The chapter provides an example of storing a number using variables, highlighting their importance in handling and representing data within a program.
01:30 - 02:00: Understanding Data Types The chapter titled 'Understanding Data Types' explains the concept of variables and data in mathematics. It begins with an example where a variable x is assigned a value of 100. This value, referred to as data, can be stored in a variable. Initially, x holds the value of 100, but this can be changed; for instance, updating x to 200. The chapter highlights that the values of variables are mutable and can change as needed.
02:00 - 03:00: Primitive vs Non-Primitive Data Types The chapter discusses the concept of variables, specifically focusing on the characteristics that differentiate variables from constants, noting that variables can change while constants cannot. It uses the example of assigning a value to a variable, such as setting an item's price, to illustrate the mutable nature of variables.
03:00 - 06:00: Working with Primitive Data Types The chapter 'Working with Primitive Data Types' introduces the concept of variables, highlighting their role as containers for storing data. It explains that a variable can hold different types of data, such as numbers, decimals, strings, or characters.
06:00 - 07:20: Difference Between Primitive and Non-Primitive Types The chapter explains the concept of variables as containers for holding data. It elaborates on how variables are used to represent data, with an example where a variable is used to store the age of a person, such as 'age = 30'. This distinction highlights that a variable, when named, refers to the data it holds.
07:20 - 08:00: Practical Examples with Data Types The chapter discusses the concept of variables in programming, specifically within the context of Java. It emphasizes that variables act as containers for holding data, and they represent this data within the program. The transcript suggests that there are specific requirements and methods for creating variables in Java, implying a foundational understanding of data handling in this language.
08:00 - 08:40: Conclusion and Summary The chapter 'Conclusion and Summary' discusses the concept of variables and data types in programming. It explains that, unlike some languages, in Java you cannot directly assign a value to a variable without first specifying its data type. Data types are crucial as they define the kind of data a variable can hold, like integers or strings, ensuring the program uses the correct operations for that type. The chapter emphasizes the significance of data types by illustrating how to assign values, like storing an integer or a string, in Java using the appropriate data type declaration.
Session 2- Working with Java Variables and Data Types | Java & Selenium Transcription
00:00 - 00:30 okay so can you see my screen everyone okay all right so in yesterday class uh we have started uh Java programming so as part of it we have seen introduction and then we have seen how we can install Java and Eclipse ID so we already installed and also seen uh a basic program right how to start creating a
00:30 - 01:00 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 and the simple programs we have seen so from today onwards we are going to start learning uh a new Concepts so Java Basics and uh any programming if you want to start learning so we need to start first like variables and how to create variables and how to use different data types how to work with
01:00 - 01:30 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 and then we will slowly learn how to use conditional statement looping statement arrays strings and so on okay so as part of today's session we will start learning variables and data types so what is variable first of all so variable is a container which can hold some some data so whenever you want
01:30 - 02:00 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 uh data okay so to represent some data we use something called variable so for example let us say uh I have to store a number let say
02:00 - 02:30 in mathematics when I say x equal to 100 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 the value of x the value of x will be the 200 that means the values of the variable can also change every time so
02:30 - 03:00 we can change the values of variables every time so that is the reason we can 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 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
03:00 - 03:30 say 10025 something like this now here this 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 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
03:30 - 04:00 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 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 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
04:00 - 04:30 name of the person let's say name equal to some X so here this is a value and 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 you want to create a variables we cannot directly create for example if you want
04:30 - 05:00 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 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
05:00 - 05:30 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 storing string data in a variable so this variable should be
05:30 - 06:00 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 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
06:00 - 06:30 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 to 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 so later I will
06:30 - 07:00 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 about variables but when you create a 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 so now if I suppose I can say x equal to 100
07:00 - 07:30 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
07:30 - 08:00 and similarly if you want to store age of the person then the data type should 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 Java syntax in the double quotations you can provide the string string is nothing but collection of characters so now what is the type of of this variable is
08:00 - 08:30 string type of variable now I want to store a grade of a student grade so 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 is car so depends on data what type of data we are storing into the variable accordingly we have to select or we have
08:30 - 09:00 to choose right data type here these are all comes under different data 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 yesterday session video okay you will understand how to install Java and eclip
09:00 - 09:30 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 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 name of the package and say finish so now it is created a new empty package
09:30 - 10:00 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 so here I'm giving some name to class let's say variables
10:00 - 10:30 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 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
10:30 - 11:00 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 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 this is scope of the class and inside the class we have a method so this is
11:00 - 11:30 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 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 a variables in Java so I will show you
11:30 - 12:00 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 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 like this I have not assign any data to
12:00 - 12:30 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 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
12:30 - 13:00 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 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
13:00 - 13:30 variable a equal to 100 so when you're 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 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
13:30 - 14:00 declared with the integer data type so you no need to specify the data type 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 later you can assign the data into the variables whenever you know the data you can assign it this is declaration
14:00 - 14:30 another one is assignment now suppose I already know the value of the variable I can simply write one single statement 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 statement end with the semicolon so this
14:30 - 15:00 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 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.
15:00 - 15:30 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 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
15:30 - 16:00 and can we put this in the double codes 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 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 statement system pin so then you will
16:00 - 16:30 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 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 value of a yes still we can change how
16:30 - 17:00 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 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 what is an output you will get here
17:00 - 17:30 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 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
17:30 - 18:00 particular statement after that a become 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 whenever it is needed okay whenever it is needed we can always change the values of the
18:00 - 18:30 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 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
18:30 - 19:00 create a variables there a First approach let's say approach 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 have Define three variables a b and c a
19:00 - 19:30 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 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
19:30 - 20:00 have written three different lines first 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 type right so instead of writing this data type into multip multiple times I can simply write only one time and
20:00 - 20:30 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 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 a variables and then can assign the data so this is a declaration this is called
20:30 - 21:00 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 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
21:00 - 21:30 this is applicable only if these variables are 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 syntax is not possible okay because we specifying the data type only one time then we can add multiple variables so
21:30 - 22:00 obviously all the variables are belongs to same data type okay now there is another approach see this approach 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
22:00 - 22:30 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 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
22:30 - 23:00 to different data types like one is 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 belongs to same data type same thing for third approach also third approach is
23:00 - 23:30 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 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
23:30 - 24:00 types okay this approach one we have to 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 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
24:00 - 24:30 from the variables so here I have defined three variables a b c and they 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 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
24:30 - 25:00 directly specify the variables inside 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 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
25:00 - 25:30 right so you can write more meaningful 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 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
25:30 - 26:00 need to do something called concatenation like this 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 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
26:00 - 26:30 so these two are two separate entities right so this is a string which we are 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 can we do this you have to do something called concatenation plus is a concatenation operator so when I say plus a then what
26:30 - 27:00 happens whatever the value we have assigned to the a that will be printed as it is in the console window along 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 is and concatenated with b and same
27:00 - 27:30 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 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
27:30 - 28:00 values from the variables now here if I look at this I have printed the values 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 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
28:00 - 28:30 using one single print statement can we print the values of all the variables 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 want to print all three values with single line so then how can we do this can we use concatenation like
28:30 - 29:00 this a first value we will print then concatenated by B then concatenated by C is it possible when I use concatenation 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 exact values so so how can we print all the values in one single
29:00 - 29:30 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 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
29:30 - 30:00 every variable and this space is just like a string okay now if I print this r 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 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
30:00 - 30:30 in the double quotations it is empty or space so when you concatenate with the 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 so this is how we can simply work with the variables you can simply work with the
30:30 - 31:00 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 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 okay so is this clear everyone please
31:00 - 31:30 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 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
31:30 - 32:00 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 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
32:00 - 32:30 right so this is all about variables so 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 a variables okay and when you create a variable you must specify the data type without data type we cannot create a
32:30 - 33:00 variable and how to decide the data type based on the data so what type of data we are storing into variable accordingly 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 of the session okay so in yesterday's class if you have any issues at the
33:00 - 33:30 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 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 types
33:30 - 34:00 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 time for that so what is data type what is data at the beginning I told you data type is nothing but what it
34:00 - 34:30 represents the type of data very simple definition so data type is always represent the type of 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 to store some data in a variable you
34:30 - 35:00 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 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
35:00 - 35:30 types second category is non primitive non primitive and these are 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
35:30 - 36:00 data types non-primitive is also called as derived data types or 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 types what are all different types are available and we can again categories to
36:00 - 36:30 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 we will use to represent number without decimal okay by short int long so these four data types we can use one of the
36:30 - 37:00 data type to represent a number without having decimal if you have a number with doesn't have any decimal then you can 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 double these two data types we can use
37:00 - 37:30 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 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
37:30 - 38:00 types bite short int long and to 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 the single quotations Single Character is always put inside the single quotations represent single code we have to use
38:00 - 38:30 character data type now there is another data type called Boolean Boolean and this particular data type we can use to 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
38:30 - 39:00 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 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
39:00 - 39:30 collections here we have string which is 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
39:30 - 40:00 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 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
40:00 - 40:30 primitive data types we can use to store 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 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
40:30 - 41:00 one single value at a time so whenever you create a variable that can hold only single value at a time so after you 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 time in a variable okay that variable
41:00 - 41:30 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 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
41:30 - 42:00 suppose let's say 100 students are 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 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
42:00 - 42:30 IDs into one single variable it is very 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 an array variable so for example let's say in a okay is equal to new in of 100
42:30 - 43:00 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 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 store 100 values I can store 100 values in a so as soon as you created a variable like this internally what
43:00 - 43:30 happens it will create 100 memory locations like this the variable name is called a and 100 we specified the size 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 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
43:30 - 44:00 one this data when I say A of one then it is representing this one when I say 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 time only one single value is allowed in a variable non primitive we can store
44:00 - 44:30 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 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 store which is called as a string but if
44:30 - 45:00 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 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
45:00 - 45:30 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 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
45:30 - 46:00 false if you want to store a string we can use non-primitive type string is 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 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
46:00 - 46:30 or long or suppose if you have a very big number let's say I have a 10 digits 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 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
46:30 - 47:00 what is the size and how much size of data the particular data type is allowed 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 bite so these four bite short int long
47:00 - 47:30 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 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 you can store which is a positive number
47:30 - 48:00 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 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
48:00 - 48:30 here + 128 here -1 -2 - 3 here Min - 128 so 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 a then I can store in a between this minus 128 to plus 128 between this range
48:30 - 49:00 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 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
49:00 - 49:30 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 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 integer data type so when you create a variable as integer data type we can
49:30 - 50:00 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 can store in integer variables and if the number is even though very bigger then long so you can see this is the maximum
50:00 - 50:30 range so most of the times we don't go more than this number this is a maximum 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 let's say l some X okay so now I have stored in X just
50:30 - 51:00 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 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 problem yes unnecessarily memory will be
51:00 - 51:30 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 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
51:30 - 52:00 choose particular data type so that will 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 higher right more than is exceeded 127 so this is not not possible we trying to store higher value in the lowest space
52:00 - 52:30 not possible okay but you can store lowest value in higher space even though the memories got wasted still you can store 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 integer more than this then you obviously go for long data type but very rare case you use that one okay so this
52:30 - 53:00 is most uh moderate data type in to representing the numbers so guys now you understood so why they have provided 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 so float is nothing but what it is
53:00 - 53:30 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 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
53:30 - 54:00 if you create a float variable and before decimal you can have any number 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 allowed okay that is a difference between float and double so most of the
54:00 - 54:30 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 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 letter okay so these are all primitive
54:30 - 55:00 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 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
55:00 - 55:30 why we need data types and how many 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 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
55:30 - 56:00 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 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
56:00 - 56:30 understand the code later okay numeric data types so I will Define two variables can see here in 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 you can create number of variables in one single line right so now I just want to print the value of a system
56:30 - 57:00 print and I just print value of a okay and also I'll write in simple meaningful message I can say the value 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 numbers I want to add these two numbers
57:00 - 57:30 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 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
57:30 - 58:00 A and B is okay now I'm keeping concatenation of WR just observe this I just written 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 observe the output see now how it has got printed so this is not our expectation
58:00 - 58:30 right so we have to get 300 but instead is just printed the value of a and b directly so what exactly Happening Here 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 directly if you print a plus b without having this
58:30 - 59:00 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 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
59:00 - 59:30 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 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 the
59:30 - 60:00 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 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
60:00 - 60:30 short and before short do we have any 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 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
60:30 - 61:00 some different variable here same variable name you cannot refer multiple 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 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
61:00 - 61:30 and minimum range this is maximum range 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 you can print so before using the data type you need to know the range actually so if you know the range exactly you
61:30 - 62:00 will know exactly which data type is AP for your data and then bite short and 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 just observe this when I use integer or when I use bite when I use short there
62:00 - 62:30 is no syntax error but when you create a long variable when you create a variable with a long data type after specifying 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
62:30 - 63:00 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 okay it can be lower case like this or it can be upper case okay now I have
63:00 - 63:30 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 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 actual value is are exactly it is printed this L will not print because
63:30 - 64:00 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 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
64:00 - 64:30 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 okay float is a smaller double is a bigger number float means it is allowed seven decimals double is allowed 15
64:30 - 65:00 decimal okay now first let us start with the float float let's create one variable called item price let's say 15 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 we are trying to store in a float
65:00 - 65:30 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 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
65:30 - 66:00 numbers like more decimal numbers okay then you can use double 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 this is mostly used double run as Java
66:00 - 66:30 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 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
66:30 - 67:00 capital l or small L at the end of the value you have to 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 some different name let's say grade and single characters we always
67:00 - 67:30 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 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
67:30 - 68:00 type so whatever value we have asend here we just printed only one single 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 so strings will represent with the double quotations string is a nonprimitive
68:00 - 68:30 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 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
68:30 - 69:00 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 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
69:00 - 69:30 seen C data type and also we have seen string data type so we understood this 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 not is the statement valid or not car CH
69:30 - 70:00 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 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
70:00 - 70:30 equal to ABC valid or not it is still invalid why even though 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
70:30 - 71:00 invalid okay now observe this one 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 the character so this is also
71:00 - 71:30 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 have a single character or multiple character doesn't matter it will treat it as a string okay as soon as you put
71:30 - 72:00 string type and double quotations that is over you can put either Single Character or multiple characters doesn't 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
72:00 - 72:30 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 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
72:30 - 73:00 which is true which is true now when I make it as 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 quotations remember this okay now let me
73:00 - 73:30 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 not it is not valid why because we put this
73:30 - 74:00 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 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
74:00 - 74:30 valid not Val because we put in the 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 true is it valid or not string BL equal to this is also not valid because this is a Boolean data
74:30 - 75:00 because we we do not put in the double quotations but the variable is what string right so this is also not valid 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
75:00 - 75:30 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 false we should not put double quotations this is a synx okay so this is all about Boolean data
75:30 - 76:00 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 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
76:00 - 76:30 use all these data types in almost in 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 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
76:30 - 77:00 to store some data we have to create a variables and what is the use of data 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 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
77:00 - 77:30 operations and then we have to know operators so there are different type of operators of in Java in the next class I 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 so once you start giving more number of
77:30 - 78:00 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 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
78:00 - 78:30 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 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
78:30 - 79:00 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 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
79:00 - 79:30 status will be false and after the 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 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
79:30 - 80:00 okay so where we can use bite data type so whenever you want to store number 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 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
80:00 - 80:30 small number you can use by data type no 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 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
80:30 - 81:00 so I put some table right so here can 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 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
81:00 - 81:30 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 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
81:30 - 82:00 Java prospective okay and for the float 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 know exact reason for so why they have put like
82:00 - 82:30 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 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
82:30 - 83:00 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 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
83:00 - 83:30 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 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
83:30 - 84:00 and suppose in future if you don't want to change the data so normally when you 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 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
84:00 - 84:30 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 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
84:30 - 85:00 have this keyword in front of the data 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 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
85:00 - 85:30 constant variable okay now you understood what is variable and constant is is a keyword 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 constant in Java we can use something called final so then this variable is a constant variable means we cannot change
85:30 - 86:00 the value at any point of so that is a meaning okay so shall we proceed in the last simple another two minutes simple 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 there are uh two kinds of programming languages statically typed programming
86:00 - 86:30 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 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
86:30 - 87:00 variables and data types so that's the 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 explained let us say in X = to 100 I have created one integer variable X and I have sto 100
87:00 - 87:30 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 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
87:30 - 88:00 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 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
88:00 - 88:30 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 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
88:30 - 89:00 allowed in Python it is allowed it is python it is allowed so why it is allowed because in Python we 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 treated as an integer X will
89:00 - 89:30 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 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 that is the reason it is dynamically
89:30 - 90:00 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 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
90:00 - 90:30 so initially here x is integer here x is 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 can change the value but the same data value we have to add but in Python we
90:30 - 91:00 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 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 actually so the python is a dynamically typed programming language Java is a statically typed programming
91:00 - 91:30 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 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
91:30 - 92:00 you can try your own also so based on 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 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
92:00 - 92:30 here and we'll continue tomorrow's session