The Java Tutorial(c) A Short Course on the Basics
Authors: Campione M. Walrath K. Hurnl A.
Published year: 2002
Pages: 34-35/125
Buy this book on amazon.com >>

Code Samples

graphics/intfig04.gif

Table 22 lists the code samples used in this chapter and where you can find the code online and on the CD that accompanies this book.

Table 22. Code Samples in Language Basics

Code Sample (where discussed)

CD Location

Online Location

BasicsDemo.java (page 65)

JavaTutorial/java/nutsandbolts/example/BasicsDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/BasicsDemo.java

MaxVariablesDemo.java (page 67)

JavaTutorial/java/nutsandbolts/example-1dot1/MaxVariablesDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example-1dot1/MaxVariablesDemo.java

ArithmeticDemo.java (page 77)

JavaTutorial/java/nutsandbolts/example/ArithmeticDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/ArithmeticDemo.java

SortDemo.java (page 80)

JavaTutorial/java/nutsandbolts/example/SortDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/SortDemo.java

RelationalDemo.java (page 82)

JavaTutorial/java/nutsandbolts/example/RelationalDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/RelationalDemo.java

BitwiseDemo.java (page 88)

JavaTutorial/java/nutsandbolts/example/BitwiseDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/BitwiseDemo.java

WhileDemo.java (page 100)

JavaTutorial/java/nutsandbolts/example/WhileDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/WhileDemo.java

DoWhileDemo.java (page 101)

JavaTutorial/java/nutsandbolts/example/DoWhileDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/DoWhileDemo.java

ForDemo.java (page 102)

JavaTutorial/java/nutsandbolts/example/ForDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/ForDemo.java

IfElseDemo.java (page 103)

JavaTutorial/java/nutsandbolts/example/IfElseDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/IfElseDemo.java

SwitchDemo.java (page 105)

JavaTutorial/java/nutsandbolts/example/SwitchDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/SwitchDemo.java

SwitchDemo2.java (page 106)

JavaTutorial/java/nutsandbolts/example/SwitchDemo2.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/SwitchDemo2.java

BreakDemo.java (page 109)

JavaTutorial/java/nutsandbolts/example/BreakDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/BreakDemo.java

BreakWithLabelDemo.java (page 110)

JavaTutorial/java/nutsandbolts/example/BreakWithLabelDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/BreakWithLabelDemo.java

ContinueDemo.java (page 111)

JavaTutorial/java/nutsandbolts/example/ContinueDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/ContinueDemo.java

ContinueWithLabelDemo.java (page 111)

JavaTutorial/java/nutsandbolts/example/ContinueWithLabelDemo.java

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/example/ContinueWithLabelDemo.java

Note

The section Common Problems and Their Solutions (page 391) contains solutions to common problems Tutorial readers have encountered .


Chapter 4. Object Basics and Simple Data Objects

http://java.sun.com/docs/books/tutorial/java/data/index.html

This chapter begins with a general discussion about the life cycle of objects. The information presented applies to objects of all types and includes how to create an object, how to use it, and, finally, how the system cleans up the object when it's no longer being used.

Next, this chapter shows you how to use objects of the following types. Classes for these objects are provided by the Java platform.

  • Character data -either a single character or a series of characters -can be stored and manipulated by one of three classes in java.lang : Character , String , and StringBuffer .

  • To work with numeric data, you use the number classes. The Number class is the superclass for all number classes in the Java platform. Its subclasses include Float , Integer , and so on.

  • You can group values of the same type within arrays. Arrays are supported directly by the Java programming language; there is no array class. Arrays are implicit extensions of the Object class, so you can assign an array to a variable whose type is declared as Object .

The Java platform groups its classes into functional packages. Instead of writing your own classes, you can use one provided by the platform. Most of the classes discussed in this chapter are members of the java.lang package. [1] All the classes in the java.lang package are available to your programs automatically.

[1] http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html

Object Basics and Simple Data Objects

The Life Cycle of an Object

Creating Objects

Using Objects

Cleaning Up Unused Objects

Summary of Objects

Questions and Exercises: Objects

Characters and Strings

Characters

Strings and String Buffers

Creating Strings and String Buffers

Getting the Length of a String or a String Buffer

Getting Characters by Index from a String or a String Buffer

Searching for a Character or a Substring within a String

Comparing Strings and Portions of Strings

Manipulating Strings

Modifying String Buffers

Strings and the Compiler

Summary of Characters and Strings

Questions and Exercises: Characters and Strings

Numbers

The Number Classes

Converting Strings to Numbers

Converting Numbers to Strings

Formatting Numbers

Formatting Numbers with Custom Formats

Beyond Basic Arithmetic

Summary of Numbers

Questions and Exercises: Numbers

Arrays

Creating and Using Arrays

Arrays of Objects

Arrays of Arrays

Copying Arrays

Summary of Arrays

Questions and Exercises: Arrays

Code Samples

The Java Tutorial(c) A Short Course on the Basics
Authors: Campione M. Walrath K. Hurnl A.
Published year: 2002
Pages: 34-35/125
Buy this book on amazon.com >>

Similar books on Amazon