站内搜索: 请输入搜索关键词
当前页面: 图书首页 > JavaServer Pages, Second Edition

JavaServer Pages, Second Edition

[ directory ] Previous Section Next Section

9.1 Expressions

Conceptually, an expression is simply a sequence of characters representing a value. Such expressions have already been encountered via the expression language used in many tags. For example, article.author.name is an expression representing the name of an author who wrote an article, as used in the Java News Today site. Expressions in Java are basically the same thing, although their syntax and meaning are different from expressions in the tag expression language.

To start with, here is an incredibly simple Java expression:

2

Obviously, this expression represents the number 2. Expressions can be more complex:

((8 / (2 * 4)) + 3) - (8/4)

This expression too represents the number 2. In this expression, +, -, * and / are called operators, as they perform an operation on two expressions to produce a result. In a numeric context, these operators do the expected things.

    [ directory ] Previous Section Next Section