wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Forward reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Forward reference" Watch "Forward reference" New topic

Forward reference

Rastogi Manish

Joined: Dec 11, 2006
Posts: 5
Can some body help me below code. It compile properly but it givec compile time error when I comment out SOP with reason illegal forward reference.

Thanks & Regards
Manish Rastogi
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243

You are trying to use the variable a before it is declared. The forward referencing rule says that you cannot use a variable on the right hand side of an assignment statement or use it to print something before it can be declared.

Hope this helps.

SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Rastogi Manish

Joined: Dec 11, 2006
Posts: 5
Ok Thanks Sankararaj

Manish Rastogi
I agree. Here's the link: http://aspose.com/file-tools
subject: Forward reference
Similar Threads
Reference an instance variable before super constructor?
static variables vs static initializers
Some funky code. Can someone explain?
try this program
Java ambigious method calling doubt