Summary: Using Classes and Objects
In this lesson, we will look the important points we covered in this chapter.
We'll cover the following...
We'll cover the following...
- The Java Class Library, which contains a collection of standard classes that we can use in our programs, is organized into packages of classes.
- We use the operator
newto create a new object of a class type. - A variable of a primitive data type contains the actual value of the data it represents. A variable of a class type contains a reference to the object that it represents.
- Characters within strings are represented by Unicode values.
- Certain escape characters are written as two characters. For example, the new-line character is
\n. - Methods within the class
Stringenable us to manipulate strings. For example, we can join two strings end to end, get the length of a string, get the character at a certain position, locate a substring, and compare strings. - We can use the class
Scannerto extract tokens from a string that is either defined in our program or read as data. By default, white space separates the tokens, but we can define other characters as delimiters. - An object of the class
LocalTimerepresents the time that it was created. We can compare two such objects and decide which one represents the earlier time. - The class
BigDecimalprovides accurate decimal arithmetic with arbitrarily large numbers. - A wrapper class such as
Integerrepresents primitive data as an object.Integercontains the methodparseIntthat converts a string containing an integer to anint. It also defines constants that represent the minimum and maximum values of anintvalue. - The class
Randomhas methods to generate numbers that appear to be random. - The class
DecimalFormatenables us to format the output of a real number or an integer according to a pattern that we create.