Junior — Middle
Can you explain what a variable is in programming?
sobes.tech AI
Answer from AI
A variable in programming is a named location in memory used to store data. It allows a program to save, modify, and use values during execution.
In Java, a variable has a type that determines what kind of values it can hold, such as int for integers or String for strings.
Example of declaring and using a variable in Java:
int age = 25;
String name = "Ivan";
System.out.println(name + " age " + age);
Here, age and name are variables that store a number and a string, respectively.