Basic HTML version of Foils prepared 18 May 97

Foil 19 Java Language -- Expressions

From Java Tutorial - Spring 1997 Part II: Java Language and Object-Oriented Concepts Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


Java's expressions are very similar to C and the following are valid:
2+3
(2+3)*i
i++ /* equivalent to i = i +1 */
(i > 0 ) && (j>0) /* Boolean */
i <<1 /* Left shift by 1 binary digit */
(i>0) ? true:false /* conditional expression */
i >>> 2 /* Signed right shift by 2 binary digits */
"fred" + "jim" is "fredjim"
/* + Equivalent to . in Perl */
(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 Thu Jan 8 1998