Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why it shows error?

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi helpers,

Considering the code below,


So I thought i is local to public void amethod(Ref r), so I declared the variable i right before Ref ref = new Ref(); and even then Iam getting the same error? Can anyone help me on this?

Regards,
Jothi Shankar Kumar. S
 
Rajesh Kadle
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, as you said i is local. We should make it class/instance variable to be visible. Please see the change below:


[ October 16, 2006: Message edited by: Rajesh Kadle ]
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajesh,

Even after making i as an instance variable, I'm getting the same error.

Regards,
Jothi Shankar Kumar. S
 
Rajesh Kadle
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should use 'r' instead of 'ref'. Error is on this variable:



Change the above code to:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic