Basic HTML version of Foils prepared 9 Sept 1997

Foil 6 Java Language -- Variable/Expression Types

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


Each Java variable or expression has a definite type, given by a declaration such as"int i;". There are three "types" of types!
  • There are Primitive or Simple types such as integers or booleans which are built-in.
  • New composite types (objects) can be constructed in terms of classes and interfaces. The type of an object is its class or interface
  • Arrays we will see are a sort of "almost" object!
First we discuss the Primitive Types
  • There are 4 integer types: byte, short, int, long of size 8, 16, 32 and 64 bits, respectively.
  • float is 32 bits, double is 64 bits. Floating point arithmetic and data formats are defined by IEEE754 standard.
  • characters are given by 16bit Unicode charset and represented as short integers.
One can use casts for conversion such as longint = (long) i; // which can be explicit as here and sometimes implied (see later)
Note booleans are either TRUE or FALSE -- they are not 0, 1 ,-1 ...



© 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