Java Reference
In-Depth Information
CHAPTER 4
■ ■ ■
Almost the Same Old Stuff
A
s we discussed in Chapter 1, one of the reasons you might be interested in MIDP as a plat-
form is that it's based on the Java programming language and the Java APIs. You'll also recall
that MIDP is built on top of the Connected, Limited Device Configuration (CLDC). The CLDC
contains most of the APIs that will look familiar to experienced Java programmers. As of this
writing, CLDC 1.0 is the most widely available version, but many newer devices are beginning
to support the CLDC 1.1 specification. We'll mention the differences between CLDC 1.0 and
CLDC 1.1 throughout this chapter.
In this chapter, we'll explore the
java.lang
,
java.io
, and
java.util
packages as defined in
the CLDC. We'll assume you're already familiar with the basic APIs of J2SE; we'll walk through
what's the same and what's different.
At the time of this writing (first quarter 2005), CLDC 1.1 and MIDP 2.0 have been imple-
mented on real devices from several manufacturers (Nokia, Siemens, Sony Ericsson, just to
name a few). The industry-wide endorsement of the JTWI (JSR 185) has prompted the rapid
adoption of MIDP 2.0. Although some JTWI devices only implement MIDP 2.0 over CLDC 1.0,
it is anticipated most new devices will be implemented on top of CLDC 1.1.
No Floating Point in CLDC 1.0
CLDC 1.0 does not support floating-point types at all. That means there are no
float
or
double
primitive types. The corresponding wrapper types,
java.lang.Float
and
java.lang.Double
,
have also been eliminated.
Floating-point support is absent in CLDC 1.0. On CLDC 1.0 devices, if calculations involving
fractional numbers are important to your application, you can perform them in software. One
implementation (using fixed-point integers) can be found at
http://home.rochester.rr.com/
ohommes/MathFP/
.
CLDC 1.1 includes floating-point support, the primitive types
double
and
float
, and the
wrapper types
Double
and
Float
. Various other classes have been modified for floating-point
support in CLDC 1.1, but the changes are minor.
java.lang
Table 4-1 and Table 4-2 list the classes and interfaces of
java.lang
and
java.lang.ref
in both
J2SE (SDK version 1.4.2) and CLDC. The CLDC columns indicate whether the class is identical
to its J2SE counterpart, is present with API differences, or is not present at all.
39
Search WWH ::
Custom Search