Using variables inside methods?
Is it acceptable to use variables you have established outside of a method, inside of a method?
For example, say I want to clear all textboxes, and this needs to happen under lots of different conditions. Could I write a method to specifically clear each actual textbox (not using a formal perimeter or anything), even though they were created outside of the method?
It works fine, I just want to know if its bad practice or if I'm gonna take a hit on my project grade.
Just to make sure I'm being clear:
private JTextField jftPlayer1 = new JTextField(10);
private JTextField jftPlayer2 = new JTextField(10);
private void resetAll()
And of course, call the method:
Every example from my textbook uses variables declared inside the method and/or formal parameters. None use variables actually declared outside the method.