Home >Java >javaTutorial >Is there var to define variables in java?
There is no var keyword in Java to create a variable, you need to follow the following syntax: Specify the variable data type Specify the variable name Optional: Specify the variable initial value
There is no var
keyword to define variables in Java
The following syntax is used to define variables in Java:
<code class="java"><数据类型> <变量名> [= <初始值>];</code>
where<data type>
Specify the data type stored in the variable, <Variable name>
is the name of the variable, <Initial value>
(optional) is the initial value of the variable.
For example:
<code class="java">int age = 20; String name = "John Doe"; double pi = 3.14;</code>
These codes define three variables: age
(integer), name
(string) and pi
(double precision floating point number).
The above is the detailed content of Is there var to define variables in java?. For more information, please follow other related articles on the PHP Chinese website!