• Post Reply Bookmark Topic Watch Topic
  • New Topic

n cannot be resolved to a variable  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I'm trying to do here is to count the vowels in an arraylist of strings. What I did may not be right, but that's not my problem for now. My problem is that i cannot return the value (n) I want to return. I don't know why and I need help.
 
Bartender
Posts: 1603
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at where the variable is declared, and where you are trying to reference it.
 
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must remember scoping rules... An identifier declared in a local scope is no longer in existence at the end of the scope...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!