Image collected

So now as we know what is a variable in a programming language, we will know about how to use it as well.

A variable must have a name. Just like your notebook has a name on it. You can name the way you want but there are some rules to maintain. We will talk about that later.

For now, suppose the name of your variable is “a”

So how will we write that?

No, that is not the exact question for Computer Science.

You need to ask,

“How will we declare a variable?”

For that you need to mention the variable name obviously. Then you need to mention what is the value there. Or you can say what are you storing on the variable. Now the variables can hold different types of data. This is why you need to get different types of space (storage memory here) as well. So you need to mention the data type also.

For Java, you can declare a variable like this way,

int a = 5;

Here we are specifying

  1. The data type using int ( for Java, int defines an integer data type, we will know about that later).
  2. The variable name “a”.
  3. The value of the variable which is 5.

A Computer Science and Engineering student. Interested in Computer Science, business analytics ,research and editing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store