wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes local variable count and array[count]: Too Many Variables to Count! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "local variable count and array[count]: Too Many Variables to Count!" Watch "local variable count and array[count]: Too Many Variables to Count!" New topic
Author

local variable count and array[count]: Too Many Variables to Count!

Robin Lane
Ranch Hand

Joined: Apr 30, 2008
Posts: 76
I'm struggling with an itty bitty little puzzle. I can't for the life of me figure out exactly what is being referred to in the following code:





Disclaimer: The author of this post makes no claims, implied or otherwise, as to her ability to understand anything but the simplest of answers. Further, the author of this post has no programming background whatsoever and has taken one Java Programming class which was 9 weeks long. She does want to learn, so please teach patiently.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18509
    
  40

but where does array[counter] come from?


It comes from the first line of the main() method, where you declared the array. Now, since you never set any of the values, they should all have the default value, which for ints is zero.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Robin Lane
Ranch Hand

Joined: Apr 30, 2008
Posts: 76
Henry, thank you so much for answering my question. I have no previous programming experience and Java is a little more abstract than the way I normally think.
 
Don't get me started about those stupid light bulbs.
 
subject: local variable count and array[count]: Too Many Variables to Count!
 
Similar Threads
Finding Nth Largest element of an array without sorting
Program Output not working
the instance variable shapes
Why is my type unexpected? required variable found value
creating object out of class of same name