您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Content Index

Content Page # 44

Introduction to expressions

An expression is a mathematical term, describing a part of a program statement that evaluates to a single value. Of course, in Java the type of value can be an object, an array or a primitive type.

Expressions are composed of operators and operands.

Expressions may be simple, such as:

7

which simply evaluates to itself, i.e. the integer constant 7.

Expressions can be complex, such as:

netTax = (float) 35.75 * ( grossEarnings + operatingProfit( 1999 ) )

which involves:

  • floating point constants — 37.75
  • conversion between types — casting using (float)
  • variables — grossEarnings
  • message passing (with arguments) and replies — operatingProfit( 1999 )

Each of the Java types has associated with it a set of operators (such as '+', '/', '&&') that can be arranged with operands to create expressions to be evaluated.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg