Basic HTML version of Foils prepared 17 Nov 97

Foil 18 java.lang.Object Wrappers

From Java Tutorial, July 1, 1996 CEWES Tutorial, CPS606, JSU Class CSC499 -- July 22-25 1997, Fall 97. by Nancy J. McCracken,Geoffrey C. Fox, Tom Scavo


1 Primitive types such as int, char, float, etc. are NOT classes. Thus one cannot use methods such as
2 int var;
3 var.toString();
4 ALL primitive types have associated wrappers:
5 Character myChar = new Character( 'A' );
6 The Character class has methods such as:
7 if ( myChar.equals( ch ) ) ...
8 System.out.print( myChar.toString() );
9 There are also many static (class) methods:
10 ch = Character.toLowerCase( myChar );
11 if ( Character.isUpperCase( myChar ) ) ...
12 The methods in a wrapper class are also useful to convert types, such as a String to a Double.

in Table To:


© 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 Wed Apr 1 1998