The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Using variable across methods

Hi, I'm looking to use the variable flagDimensions in method norwayFlag after defining it as shown. However, it's telling me that the variable is undefined. Please ignore the UI. etc, it's part of a custom library used by the learning institution. Please also note that this is not the whole code, just the relevant piece.
So, what have I done wrong?! Thanks!

Re: Using variable across methods

It's a bit difficult to say *how* you should do whatever it is you want to do without knowing first what it *is* that you want to do.

Currently the flagDimensions() method does nothing at all. It assigns some values to the parameter variables, but these variables last only as long as the method does. Ie they will "go out of scope" - disappear without trace - after the method finishes, so assigning anything to them is without any lasting effect.

As far as the fillRect() method is concerned, look in the documentation for that class and see what sort of arguments it expects you to pass it. (The number and type of those arguments)