📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

Variables in Java (Hindi) | What is variable? full Explanation with types

Learn Coding4:30

Transcription

Subscribe to our channel to learn about variables. Hi friends, in today's video I'll explain variables: what they are and their types. We'll discuss all this. First, understand the meaning of a variable. A variable simply means something changeable; you can change its value. Now, I'll give you its definition, and then we'll discuss it further.

It's a user-defined name given to a memory location. The user-defined name can be anything. It stores a specific type of value. That's the definition. Let me explain this with a diagram. This will clear any doubts you may have. I'm creating a memory here. This is our RAM. If you want to store data in a particular memory location—say, we have data "train"—and we want to store this data in this memory at a specific location, or let's say there's some data in this location, like "ten," and we want to access it, we can't do it without knowing the location's name. Until we give this location a name, we cannot store data in this location or access its data.

A real-life example: If someone wants to call you, they need your name to do so. If I write "Intel Core i7" here, this becomes our location name. This is our storage location. I've named this location. So, if I want to access this data, I can use this name to access it. This is the name of our variable. If I want to store "Spain," I can use this name to store it here. Memory space will be allocated for this variable to store your data. I said variables are changeable; you can change their values later. If I write "Kepler-10b" here, it's possible because we can change the value. Variable means combination; "vary" means to change. If you increase the value, it is also possible. The user-defined name can store any type of value. If I write "Sun 20.5" here, that's also possible. Our "ten" will be removed, and this will be stored instead. It can store any kind of value.

Now, let's see how many types of variables there are. There are three types of variables: the first is a local variable, second is a static variable, and the last one is an instance variable. I'll explain what these are, their syntax, and show you how to implement them in a program in my next video. If you liked this video, like it, share it, and subscribe if you're new to the channel.