File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Local Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Local Class" Watch "Local Class" New topic
Author

Local Class

Sarma Lolla
Ranch Hand

Joined: Oct 21, 2002
Posts: 203

When the above code is executed the CTOR doesn't get printed. Can any one explain?
Tom Adams
Ranch Hand

Joined: Feb 07, 2003
Posts: 56
I think all you need to do is put the local class definition (c1 class) before the
c1 c123 = new c1();
line. At least that worked for me. I actually received a compiler error on the original source. Which I think is called a forward reference error(?).


Tom
Maria Garcia
Ranch Hand

Joined: Jul 14, 2002
Posts: 86
Sarma,
The code you posted does not compile on my machine:
Try this code:


SCJP 1.4
Dan Culache
Ranch Hand

Joined: Jan 24, 2003
Posts: 70
Maria, I believe Tom's explanation is correct.
Your code refers to regular inner classes and Sarma's code refers to method-local inner classes.
So it looks like when you define a method-local inner class you cannot forward reference it like you can with a regular inner class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Local Class
 
Similar Threads
Stuck in garbage collection???????????
class loading
How many object are eligible?
Number of Objects eligible for Garbage Collection
Circular Reference...