Variables are places where temporary values are stored.
Just that.
Are you serious?
Yes seriously, if you want a longer one...
…let's see what it means from Wikipedia:
Variables: (Lat) 1. variable, not fixed; 2. declaration of something that has a variety of values 3. different in programming languages are also called symbols that represent certain values, variables known in sub programs are called local variables. being known in general / intact in one program is called a global variable.
Well, don't you know?
Otherwise, just understand: Variable as a place to store temporary values.
Then, what is a data type?
A data type is a type of data stored in a variable.
Various Data Types
The following are the various data types in Java:
▶️ char: Character data type, example Z
▶️ int: number or integer, example 29
▶️ float: decimal number, example 2.1
▶️ double: decimal number too, but larger capacity, example 2.1
▶️ String: a collection of characters that make up text, eg Hello World!
▶️ boolean: a data type that only evaluates to true and false.
Creating Variables
The thing to know in creating variables in java is how to write them.
The format is like this:
Example:
Create an empty variable of type integer:
Create a variable of type integer and directly fill in the value:
Create a set of variables of the same data type:
So, where is it written?
Inside the main() function: the variables written in the main() function and other functions are called local variables.
Inside the class: These variables are called class or global variables.