![]() |
VOOZH | about |
In Java, variables are containers used to store data in memory. Variables define how data is stored, accessed, and manipulated. A variable in Java has three components,
Age: 25 Name: GeeksforGeeks Salary: 50000.5
The image below demonstrates how we can declare a variable in Java:
From the image, it can be easily perceived that while declaring a variable, we need to take care of two things that are data type of the variable and name.
It can be perceived with the help of 3 components explained above:
Example: Here, we are initializing variables of different types like float, int and char.
Simple Interest: 5.5 Speed: 20 Time: 10 Character: h
Related articles: