So I'm writing my first game in Java, and I'm following a tutorial series on Youtube. I've come to a point where I'm going to start cleaning up the code before I move on. One thing the tutorial says to do that doesn't seem very wise is to declare new variables in the tick( ) and render( ) methods that run dozens of times per second. Wouldn't using class level variables in the tick and render functions be faster because the program can skip the creation and deletion of said variables.
Another thing that I was going to do was encapsulate all of my class level variables. My college professor said it is a good practice and he actually made us do it. Eventually I learned to like the consistency of only using get/set methods when accessing class level variables. However, in game programming, I've had lots of variables so far that are never accessed outside the class. Should I only make get/set methods for variables accessed outside the class? Do get/set methods hurt performance at all?