> [...]
>
[quoted text clipped - 15 lines]
> }
> }
thank you Leon.. so every time you have nested classes, when you
compile, the nested class becomes a class of its own? this happens
every time you nest one class inside another? (except in a servlet, I
suppose (which of course is techn. a class......;).. I mean classes
inside a servlet are not techn. inner classes, right?)
(so here yr inner class has a diff. name from main class.. in my ex.
(taken from a real package w/a whole lot of classes) this comes from a
source code file called Connect.java, ran a search for word "class" in
it, I don't see any nested classes (no inner classes called "Connect" at
any rate..) thanks again, Leon... Frances
Andrew McDonagh - 14 Jun 2005 23:12 GMT
>> [...]
>>
[quoted text clipped - 27 lines]
> it, I don't see any nested classes (no inner classes called "Connect" at
> any rate..) thanks again, Leon... Frances
Leon's example is unfortunate that it described 'named' inner classes.
When compiled you should see the likes of
Outer$NamedInner.class
Whereas what you are seeing :
Connect$1.class
Connect$2.class
Connect$3.class
is the binary class files for 'anonymous' inner classes.
e.g.
public void someMethod() {
////////////////// This is the anonymous class...
Runnable r = new Runnable() {
public void run() {
System.out.printLn("do something when called");
}
};
////////////
r.run();
}
Runnable is an standard Java Interface, but anonymous classes can also
be derived from normal classes too in the same way as above.
Andrew
}
Leon - 15 Jun 2005 00:03 GMT
[...]
>>> An inner class is a class within a class:
>>>
[quoted text clipped - 8 lines]
>>> }
>>> }
[...]
> Leon's example is unfortunate that it described 'named' inner classes. When
> compiled you should see the likes of
[quoted text clipped - 23 lines]
>
> ////////////
[...]
Understood. Thanks for explaining..
Greetings, Leon
Juha Laiho - 17 Jun 2005 21:20 GMT
Frances Del Rio <fdr58@yahoo.com> said:
>> An inner class is a class within a class:
>>
[quoted text clipped - 14 lines]
>suppose (which of course is techn. a class......;).. I mean classes
>inside a servlet are not techn. inner classes, right?)
It's not often when you see inner classes in a servlet. Note the
construct above; there's the top-level class declaration (class OuterClass),
and completely nested within it another (class InnerClass).
When you write a servlet, you pretty much have
public class MyServlet extends HttpServlet {
// ... variables and methods for MyServlet
}
Of course, there's no restriction why you couldn't have inner classes
within servlets, but I think that'd rather often indicate that there's
too much processing logic in the servlet (instead of decoupling the
logic to a set of generic classes, and only using servlets to create
a web interface for the logic).

Signature
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
Tor Iver Wilhelmsen - 18 Jun 2005 12:51 GMT
> public class MyServlet extends HttpServlet {
> // ... variables and methods for MyServlet
> }
Well, usually just methods. Putting state in a servlet - especially
state related to requests - is evil. State belongs in request, session
or application scope explicit, not in any servlet class variables.