Skip to playerSkip to main content
Confused about Java data types and variables? 🤔 In this beginner-friendly tutorial, I’ll walk you through all the essential Java data types using a clear and relatable student information example.
You’ll learn: ✅ What variables are and how they work in Java
✅ The most common data types: , , , , , ,
✅ How to declare and initialize variables
✅ How to use variables to store student info like name, age, grade, and enrollment status
✅ Best practices for clean and readable Java code
This tutorial is perfect for students, aspiring developers, and anyone starting Java in 2025. Whether you're using NetBeans, IntelliJ, or VS Code—this guide will help you master Java variables with confidence!
📌 Don’t forget to like, subscribe, and hit the 🔔 for more Java tutorials!
#JavaTutorial #LearnJava #JavaDataTypes #JavaVariables #StudentInfoExample #JavaForBeginners #Java2025 #CodingBasics #ProgrammingTutorial #JavaCoding #TechSkills2025
Transcript
00:00hello friends in this video we gonna learn about data types and variables okay why we use data
00:06types and variable because we have to store some data to process in our program okay to get some
00:12results so that's why we use data types and variable because we have to we create program
00:18to store and process data okay so how can we do that we have different types of data like
00:26integer okay to store any number and the other data type is double or float okay so integer are long
00:42let me explain it to you all okay and str char for storing single character and the other one is
00:49boolean and the last one is string okay so you can see the mostly used okay data types are integer
01:07are long okay integer have some limits like like if integer have a limit minus three two it's just for
01:16your information okay minus three two three okay the long have much deeper limit like minus 10 to 10
01:25okay like that it's not the exact number it's just for your information like why we use int and if we
01:32have very large number okay then we store in long okay otherwise we store in it long is also integer type
01:41okay same like that double range much higher than float okay float is directly to integer okay
01:56only the limit issue okay otherwise not an issue charge only store a character like a b c d any character
02:12if we want to store in our program and process like student c jp okay if we have to store it we use char
02:20if we check if our student is pass or not okay so we use boolean it only store true okay true or false
02:34and the string is used to store any character array like this one okay you can store any data in string okay
02:49so let's understand okay how to declare a variable and how to assign value to it okay so first of all
02:59let we create a program that store user information okay a student information
03:07student info
03:12so first of all we have to store the id so id
03:19is it student id how can we assign a value to it okay we have to
03:29first of all we have to tell java what is the data type okay what's the data type we are using
03:37we use integer type data okay because id is not too big okay so that's why we use integer
03:45here like 43
03:52and then height
03:56what's the data type of height okay so we're gonna use float
04:00what's the data type of height okay okay 5.8 and we have to put f because this one is our floating
04:23point number okay
04:27and then great okay rc gpa
04:33it also type float
04:37c gpa
04:40which is four point sorry 2.6 like
04:45and we have to put f at the end okay because this one is floating type
04:53and then
04:56grade okay
05:01so grade is type char
05:03and we have to assign some value we have to put any character okay single character in single
05:12quotation okay and grade is e
05:19and the last one username okay student name is like we have to declare a variable name and data type data
05:29is string because we have to put a string type because our name is type string okay
05:38so funny
05:41that's all so how can we print in the console okay
05:45okay
05:53you can see i put uh intelligence in my id you can see in the tools options
06:01and code completion okay you have to select java
06:06and you have to check this both and apply okay apply and okay
06:09so it will also hint you okay so you just have to type s out and once you
06:17print tab to autorite system dot out dot print line okay so first of all we have
06:24to print ID which is equal ID you simply need to copy and put it here
06:39so we have to put height here and height
06:57and then CGP
07:09great and last one is name okay
07:23so why we I use plus here this is a syntax in Java okay that concatenate that merge
07:39okay you can see the value will be here okay so we use plus sign to concatenate
07:47with this string okay like let me show you an example string user info okay which
08:00is equal to you have to put a string like that and then you you have to use plus
08:07sign okay and name and then plus sign and age plus age okay so this is how you
08:19can integrate okay concatenate the data into one string okay so that's why we
08:27use plus sign to concatenate this data with the ID to print in a particular line
08:34okay so let's first turn this one and check what's the output
08:47you can say ID ID CGP a great key so if I would change the value okay like ID is
09:04equal to 23 what would be printed variable whose value change during the
09:10program execution it's execute line by line okay statement was statement first
09:15of all what's the value in ID 43 so when this statement executed it overwrite the
09:21value okay so 43 is replaced with quantity so that's why we called it variable whose
09:30value change during the program execution you can see it's 23 now and you may change the name
09:37you have to declare one time okay you can't read declared like you have to declare only one time string name
09:54okay once you have to assign value you don't need to declare the data type again okay so you can see name is changed
10:04CGP a 3.3 and you have to put F to show its floating point
10:18so you can see our value is going to change during the program execution okay so like you have to create a program that print student for our two semester grade okay so what we have to do we have to print s out and tab here and smash it to the
10:46test out and tab here and semester 0 1 c gpa and grade ok and see I simply copy it and paste it here
11:10okay and here we just need to change the variable values only let me tell you how you can do this
11:19you just need to remove the
11:23data types okay
11:34okay and once I run this program sorry we have to change the semester 1 to 2 here okay and we have to change the values like 2.7 or 2.9
11:54grade is t and once I run it again you can see
12:04first output you can see student semester 1 c gpa 43 height is constant okay it is also
12:16static cost we don't need to change the student information okay we also need to change the
12:23student student c gpa and grade okay
Be the first to comment
Add your comment

Recommended