The Java TM Tutorial

| Start of Tutorial | Search

## Trail: Essential Java Classes

> > Your feedback is important to us! If you have comments about this trail, send them to: tutorial@java.sun.com. In your message, put essentials in the subject header.

> This trail discusses classes from the Java platform that are essential to most programmers. In particular, it focuses on classes from the `java.lang` and `java.io` packages, including these:
> - `String` and `StringBuffer`
> - `Properties`
> - `System`
> - `SecurityManag`er
> - `Thread` and its related classes
> - `Throwable` and `Exception`, and their friends
> - The `Reader`, `Writer`, `InputStream`, and `OutputStream` classes from `java.io` and their descendants
> Like the rest of the tutorial, this trail is designed so that you can skip around. Feel free to read only the lessons for the classes that interest you.

> Using String and StringBuffer illustrates how to manipulate character data using the `String` and `StringBuffer` classes. It also teaches you about accessor methods and how the compiler uses `String`s and `StringBuffer`s behind the scenes.

> Setting Program Attributes describes how you can set attributes for your Java programs through the use of properties and command-line arguments. Use properties to change attributes for every invocation of your program; use command-line arguments to change attributes for only the current invocation of your program.

> Accessing System Resources shows you how, through the `System` class, your Java programs can manage properties, set up a security manager, and access system resources such as the standard input and output streams. The `System` class provides a system-independent programming interface to system resources, thus allowing your programs to use them without compromising portability. This lesson also contains a brief discussion of the `Runtime` class and why most programmers should avoid using it.

> Handling Errors with Exceptions explains how you can use Java's exception mechanism to handle errors in your programs. This lesson describes what an exception is, how to throw and catch exceptions, what to do with an exception once you've caught it, and how to best use the exception class hierarchy provided by the Java platform.

> Doing Two or More Tasks at Once: Threads discusses in detail the use of threads that enable your Java applications or applets to perform multiple tasks simultaneously. This lesson describes when and why you might want to use threads, how to create and manage threads and thread groups in your Java program, and how to avoid common pitfalls such as deadlock, starvation, and race conditions.

> Reading and Writing (but No 'rithmetic) describes the process of getting information into your program and sending it out again through the use of the stream classes in `java.io`. Reading and writing information provides the basis for all kinds of interesting behaviors, such as serializing objects, invoking methods on objects in another VM, communicating over a network, or just accessing the file system.

| Start of Tutorial | Search