| Author |
A class defined within a method
|
Kasey Tritt
Greenhorn
Joined: May 02, 2002
Posts: 15
|
|
What is really meant by the term "a class defined within a method"? This term is sometimes used in the exam. Definitions Local Classes are specific to a block of code. Their visibility is only within the block of their declaration. Anonymous classes are classes which have no name. They combine the process of definition and instantiation into a single step. Does anyone know the term "a class defined within a method" refers to a local class or anonymous class or both?
|
 |
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
|
|
Originally posted by Kasey Tritt: Does anyone know the term "a class defined within a method" refers to a local class or anonymous class or both?
A class defined within a method could be either a local class or an anonymous class. Here is an example where one of each is defined within a method: You see, both local classes and anonymous classes can be defined within a method. However, in general, when someone is referring to a class defined within a method, I would presume their talking about a local class, which is the first example. I hope that helps, Corey
|
SCJP Tipline, etc.
|
 |
Kasey Tritt
Greenhorn
Joined: May 02, 2002
Posts: 15
|
|
That certainly helps! Thanks, Corey.
|
 |
 |
|
|
subject: A class defined within a method
|
|
|