Basic HTML version of Foils prepared 9 Sept 1997

Foil 9 Java Language -- Expressions

From Java to be used in (Scientific) Computing Part II: Java Language and Object-Oriented Concepts Basic Simulation Track for Computational Science CPS615 -- Fall Semester 97. 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 Sun Feb 22 1998