Home >Java >javaTutorial >How to assign value to short type in java
The short type in Java is a 16-bit signed integer ranging from -32,768 to 32,767. The assignment syntax is: short variableName = value; where variableName is the variable name and value is the assignment value (integer literal value, variable or expression result).
Short type assignment in Java
The short type is a 16-bit signed integer type in Java. The range is -32,768 to 32,767. To assign a value to a short type variable, you can use the following syntax:
<code>short variableName = value;</code>
where:
variableName
is the name of the short type variable to be assigned a value. value
is the value to be assigned to the variable, which can be an integer literal, a variable, or the result of an expression. Example:
<code>short age = 25;</code>
In this example, age
is a short type variable and is assigned the integer literal value 25.
Note:
(short)
) to convert values of other types to the short type. The above is the detailed content of How to assign value to short type in java. For more information, please follow other related articles on the PHP Chinese website!