This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Illegal forward reference  RSS feed

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into this partial code listing:

Thanks in adv.
 
Henry Wong
author
Sheriff
Posts: 22831
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

private String s = s;//illegal forward reference error. What does it mean?


Well, it is an illegal forward reference because you are declaring a reference "s" and trying to initialize it to itself.


I am assuming that you wanted to initialize it to the "s" reference in the outer class? Which quite frankly may not be visible during this initialization.

Henry
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
Well, I read that "a method-local inner class can access private or any other members of its enclosing class." Based on this statement, I was trying to access a "private String s" variable of outer class. Is the above statement wrong?
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry, look into this code now:

I can conclude that outer s is visible inside the method!
 
Henry Wong
author
Sheriff
Posts: 22831
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can conclude that outer s is visible inside the method!


It is in the second example. But I was referring to your first example.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!