#2.1 Java VARIABLES and DATA TYPES Part-1. Java Tutorial for Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi this is shrinks at the hearth once again welcome to the next video of this series of Java fundamentals and basics in this video we will learn about what are variables and data types in Java so for that first let us take some example such as if I ask you to define a value 10 that is a number 10 in Java let's say this 10 is suppose your age so how you will do it now the Java would understand your normal speaking language right so you have to make Java understand in its own way so to make Java understand that this 10 is actually your age so you have to first define 10 value and then you have to declare a variable name such as age now you have 8 and 10 so how you will combine these two and how you will let Java know that this 8 is actually the integer value or some numerical value so for that we have a data type such as int so int space age and then followed by equal to sign followed by 10 and then end this statement with the help of a semicolon like we use . in case of english language we use a semicolon to end a particular statement in Java so that the Java will know that this completes your one statement so now you have simply made the Java understand that this age is actually having the value of 10 and what determines that this age contains a number value is with the help of this data type of int so at the end we can say this 10 is actually the value and then this age is actually the variable name and then this int is actually known as the data type so this integer that is the data type determines that this variable name age can contain the value of a number that is 10 20 64 and so on and now next suppose I tell you to tell Java your name so suppose my name is Trang and what is tree and it is actually my name so you have to tell Java in its own way that string space name equal to strength now again this string is actually their datatype and this name is actually the variable name equal to the value and this value is shrink enclosed within the double quotes now what this string stands for I will let you know shortly and now at the end suppose if I ask you to declare is shrink alive or not if he is alive then simply print true or if he is dead then simply put the value as false so either true or false right so for that I have a special data type of bouillon bouillon space is alive equal to true yes shrink is alive and his age is pen now again this boolean can be either true or false right and now proceeding forward let us check out what is exactly a variable so here int h equal to 10 where this 8 is actually the name of the variable right so let us talk about what is a variable in Java so to define a variable it is the name of the reserved area allocated inside the memory now whenever you run your Android application or some java application or any other application then it consumes some memory not that memory is actually consumed partly by these variables such as int h equal to 10 consumes some memory of your device right so this variable is actually the name of the area allocated inside your memory and now there are basically three types of variables in Java such as the first is the local variable instance variable and then the static variable or the class variable now we will discuss about all these types of variable in Java in our upcoming modules not in this module because as a beginner I don't want to bombard with lots of knowledge initially in this course let's keep it pending for our upcoming modules and now proceeding forward what is a data type in Java so here in this example int age equal to 10 here this int is actually known as the data type as we all know from the previous slides so how can we define a data type now the data type in Java represents the different values to be stored in the variable so what this age should contain a number a boolean value or some string value is actually determined with the help of this int data type suppose if I put here string then this age will carry your name right something like that so what are the various types of data types in Java so in Java we have the primitive and non primitive type of data to be broadly categorized so let us check out what is a primitive and non primitive type of data so here as we all known this int is actually the data type so the data type is broadly categorized into primitive and non primitive type of data now this non primitive type of data is also known as the reference type or the object type of data so let us come to this primitive type of data so here in the primitive type of data we have these examples such as boolean care byte short int long float and double now please make a note here here all these primitive type of data starts from a small letter small B small C and so on till double right and here on the right hand side we have the non primitive or the reference type or the object type of data so let us take some example here so we have examples here as string array and even we can define our own custom type of data such as employee object student object home office company laptop and so on right so we will cover the non primitive type of data in our upcoming modules in a lot more detail and now let us throw some light on this primitive type of data so here in case of primitive type of data we have boolean bite care short int long float and double right now whenever we run our application all these primitive datatypes consume some memory right so these memory varies for each of the data type such as the boolean takes one bit byte takes 8 bit and so on till the end double now the double and the long takes a large amount of memory such as 64 bit the float and int takes 32 bit and similarly short care takes 16 bit and so on right and now apart from size here we have some default value as well so whenever you declare some primitive datatype without giving it some value we have some default value as well such as a boolean value is by default contains the value of false byte contains 0 character and teens this value short int and long contains 0 and down the side we have float and double now float and double actually contains the decimal point values so by default it has the value of zero point zero and zero point zero respectively now here we have F and D so whenever we define a float value and the double value we actually provide a suffix of F and D respectively and now let us take some example of the values that we can store inside these data types so on the right hand side I have some examples such as the boolean can be true or false the byte can store the value ranging from minus 127 to 128 character can be a single alphabet or some special escape characters or some integer value now here make a note all these values are actually enclosed within a single quote such as a has been enclosed by one single quote here and one single quote here and then we have the integer value as -2 and one two three four five six seven eight and so on so it is basically the integer values that we check in case of mathematics and in case of long we have minus 2 L minus 1 L and so on and then comes the floating point value and the double value that accepts the decimal values such as three point four four point six F and so on right and please make a note here we have small F and capital F so you can use either small F or capital F to declare any floating point values now similarly in case of double values we can use either small D or capital D it is totally up to your wish so this is all for this video so in the next video we will check out the primitive data types in a lot more detail in our demo video in our IntelliJ IDE that is we will start coding from the next video onwards so meanwhile if you like what you saw please subscribe to my channel smart hood and please do leave a comment below the video this is raised from smart hood signing off thank you
Info
Channel: Smartherd
Views: 40,640
Rating: 4.9053879 out of 5
Keywords: android, smartherd, java, data type, variables, primitive data type, non primitive data type, object type, reference type, java tutorial, boolean, char, int, float, double, String, long, byte, java tutorial for beginner
Id: iFzA43xR04s
Channel Id: undefined
Length: 10min 3sec (603 seconds)
Published: Mon Jun 19 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.