Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

explanation needed.

 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The declaration of a member needs to appear before it is used only if the member is an instance (respectively static) field of a class or interface C and all of the following conditions hold:

* The usage occurs in an instance (respectively static) variable initializer of C or in an instance (respectively static) initializer of C.
* The usage is not on the left hand side of an assignment.
* C is the innermost class or interface enclosing the usage.


can anyone explain me the last line.......does it mean

class Ankur
{
int x;
class Ankur1
{
int y=x;
}
}

is allowed ......but when it cant be allowed? what am i missing here?
 
Sonali Sehgal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankur,
Please be more specific in your question there is not interfaces in this program and no variable or class name C.Please make your question more clear.
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but there is an inner class.....i codunt udnerstand the last point
 
Sonali Sehgal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi Ankur ,

What I meant to say there is nothing as C in this program......


This is a program of Outer class and Inner class.In case of Inner class it can access private,protected ,default and public or any access modifier variable in inner class and declaring int y can take in that particular x variable of the outer class.
 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur, where did you find that statement?? If we look at it in the context in which it is said, it might make sense.

Sonali, the text quoted by Ankur says C is a class/interface. So basically its just an identifier (name) for a class/interface...
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i quit.....i am unable to understand anything that is being posted today.....
 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur kothari wrote:i quit.....i am unable to understand anything that is being posted today.....

What did you not understand in this??
Ankit Garg wrote:Ankur, where did you find that statement??
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nothing leave..thanks for asking
 
Henry Wong
author
Marshal
Pie
Posts: 20993
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, if you are going to quote the JLS, you should say so ... along with providing a note that states to which section you are quoting from.

The JLS is like legalese, to quote it out of context, is the quickest way to confuse people, or to wind up with nonsense.


All the statements are saying is that certain types of forward referencing is not allowed -- and are listed in that section of the JLS.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic