Basic HTML version of Foils prepared Sept 21 1998

Foil 10 Java Language -- Expressions

From Java Tutorial 98- 2: Java Language and Object Oriented Techniques NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken


Java's expressions are very similar to C and include the following forms. Both expressions and statements have values.
  • arithmetic:
    • 2+3
    • (2+3)*i
  • autoincriment and autodecriment
    • i++ /* equivalent to i = i +1 */
  • boolean
    • ((i > 0 ) && (jɬ)) ||(state = -1)
  • bit operations
    • i <ə /* Left shift by 1 binary digit */
  • conditional expression
    • (iɬ) ? expression1 : expression2
  • strings have operators such as catenation
    • "fred" + "jim" is "fredjim"
  • object property operators
    • (a instanceof B) /* True iff object a is of class B */



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998