The
word to watch for when reading up on this kind of thing is "scope", that is how long does the variable live. A local variable exists only until the method returns. If you build up some temporary strings it's good to let them go out of scope when you return.
You can make an even shorter scope inside a pair of curly braces. If you declare a variable within a loop or if clause then it goes out of scope at the end brace.
If you build up a value that you'll need again later, losing it would be a bad thing. It would be better to make it a member field or static field. A member field scope matches the object instance; it's good until the object is no longer referenced. A static field scope is probably until you stop the JVM, though you could muck about with class loaders and get some sort of custom scope in controlled situations.
[ August 30, 2007: Message edited by: Stan James ]