Java Reference
In-Depth Information
Self-Test Exercises
27. What would be the last line in the dialog in Display 4.18 if the user entered the
following input line instead of the one shown in Display 4.18? (The comma is
omitted.)
Savitch Walter None
28. What would be the last line in the dialog in Display 4.18 if the user entered the
following input line instead of the one shown in Display 4.18?
VideoNote
Example Using
the String
Tokenizer Class
on a CSV File
Tom, Dick, and Harry
Chapter Summary
Objects have both instance variables and methods. A class is a type whose values are
objects. All objects in a class have the same methods and the same types of instance
variables.
There are two main kinds of methods: methods that return a value and void meth-
ods. (Some specialized methods, such as constructors, are neither void methods nor
methods that return a value.)
When defining a method, the this parameter is a name used for the calling object.
Normally, your classes should have both an equals method and a toString method.
If an instance variable or method is marked private , then it cannot be directly
referenced anyplace except in the definition of a method of the same class.
Outside of the class in which it is defined, a private instance variable can be accessed
via accessor methods and changed via mutator methods.
A variable declared in a method is said to be a local variable . The meaning of a local
variable is confined to the method in which it is declared. The local variable goes
away when a method invocation ends. The name of a local variable can be reused for
something else outside of the method in which it is declared.
A parameter is like a blank in a method definition that is filled in with an argu-
ment when the method is invoked. A parameter is actually a local variable that is
initialized to the value of the corresponding argument. This is known as the call-by-
value parameter-passing mechanism.
If a variable is used as an argument to a method, then only the value of the variable,
not the variable itself, is plugged in to the corresponding parameter.
 
Search WWH ::




Custom Search