Home >Java >JavaBase >what is java expression

what is java expression

angryTom
angryTomOriginal
2019-11-13 17:37:003871browse

what is java expression

What is a java expression

In the Java language, an expression is composed of a variable or a constant A combination of and symbols, for example: num1 num2; or age>18;, etc.

The symbols commonly used in expressions are called operators, and the variables or constants that these operators act on are called operands.

For example: In the expression age>18, age and 18 are operands, and the symbol > is the operator.

In some complex operations, simple expressions can be combined into complex expressions, and the operand itself may be an expression. For example, (num1 num2) * (x y), where the operands (num1 num2) and (x y) are themselves expressions and are multiplied by the operator *.

The evaluation result of the expression must be a value. If the expression is a condition, it will produce a logical value result, that is, true or false. In other cases, the value is usually the result of a calculation.

Legitimate expressions in Java language

① a*b 2

Among them, a, b, 2 are operands, a and b is a variable, 2 is a numerical constant, and is the operator

② 'a' 3

Among them, 'a' is a character constant, and its value when participating in the calculation is the encoding of the character set in which the character is located. Value, is 'a' ASCII? Yes, the expression 'a' 3 is equivalent to 97 3

③ "study" "java"

where, "study" and "java" are characters String constant, is an operator. If the operands on both sides of the operator are string constants, the calculation result is the connection of the two string constants, and the expression result is "study java"

Classification of expressions in Java language

Expressions can be divided into various categories, depending on the type of operator used. The main categories of Java language include: arithmetic expressions, assignment expressions, conditional expressions and logical expressions.

php Chinese website, a large number of free Java introductory tutorials, welcome to learn online!

The above is the detailed content of what is java expression. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn