Java Reference
In-Depth Information
System.out.println (s1.length());
System.out.println (s2.length());
SR 3.8
Write a statement that prints the value of a
String
object called
title
in all uppercase letters.
SR 3.9
Write a declaration for a
String
variable called
front
, and initialize it to
the first 10 characters of another
String
object called
description
.
We mentioned earlier that the Java language is supported by a standard class
library that we can make use of as needed. Let's examine that idea further.
A
class library
is a set of classes that supports the development
of programs. A compiler or development environment often comes
with a class library. Class libraries can also be obtained separately
through third-party vendors. The classes in a class library contain
methods that are often valuable to a programmer because of the special function-
ality they offer. In fact, programmers often become dependent on the methods
in a class library and begin to think of them as part of the language. However,
technically, they are not in the language itself.
The
String
class, for instance, is not an inherent part of the Java language. It is
part of the Java standard class library that can be found in any Java development
environment. The classes that make up the library were created by employees at
Sun Microsystems, the people who created the Java language.
The class library is made up of several clusters of related classes, which are
often referred to as the Java APIs, which stands for
application programming
interfaces
. For example, we may refer to the Java Database API when we're
talking about the set of classes that helps us write programs that interact with a
database. Another example of an API is the Java Swing API, which refers to a set
of classes that defines special graphical components used in a graphical user inter-
face. Often the entire standard library is referred to generically as the Java API.
The classes of the Java standard class library are also grouped
into
packages
. Each class is part of a particular package. The
String
class, for example, is part of the
java.lang
package. The
System
class is part of the
java.lang
package as well. We mentioned in
Chapter 2 that the
Scanner
class is part of the
java.util
package.
The package organization is more fundamental and language-based than the API
names. Though there is a general correspondence between package and API names,
the groups of classes that make up a given API might cross packages. In this topic, we
primarily refer to classes in terms of their package organization.
KEY CONCEPT
A class library provides useful sup-
port when developing programs.
KEY CONCEPT
The Java standard class library is
organized into packages.
Search WWH ::
Custom Search