On Tue, 22 Jun 2010 16:02:27 -0700, markspace <>
wrote:
Good morning Mark, and thanks.
>Mike Barnard wrote:
>> public class starnumbers
>> {
>> int[] numberStore; // A place to store all of the numbers.
>
> static int[] numberStore;
>
>This is an easy one. Just make the change that I added above and you're
>good to go.
I knew static was relevant but had no concept of what it meant. But
Now I know, I think. See reply to other message below.
>To try to explain this a bit more, static on a method means that the
>method isn't attached to any one instance of the class, it's attached to
>the class itself. Same for variables. Static means they're attached to
>the class (sort like a "global" variable) and not static means the
>variable is attached to an instance.
And as I had / have no instance as such... kablooey.
>The problem with what you had was a static method was trying to access a
>non-static (instance) variable. And you don't have an instance in that
>case. So, it fails.
Heh, wot I said.
>The other thing you could have done, is not make the change I gave you,
>then do something like this:
>
> public static void main( String... args ) {
> starnumbers sn = new starnumbers();
> int number = 5;
> sn.numberStore = new int[number];
> // ...
>
>See? Now I have an instance, referred to as "sn", so I can use the
>instance variable called numberStore with it.
>Hope that made sense.
>
>(P.S., also, please use proper capitalization of your class names, e.g.
>"StarNumbers".)
OK, refreshed on that too.
Thanks for taking the time to reply in a way a tiny brain like mine
can understand!
Mike.