If all you ever do is assign the String variable some value, then it will be recognized as an unused variable. The code must use that value (as a parameter to a method, in a String comparison, etc...) for the variable to not be considered unused. And it's straightforward to see why this is so: that variable is like a black hole; values go in but never come out to be used again. It's a dead-end, having no effect on subsequent code. It might as well not exist.