What is the best practice for initializing a String method (local) variable to avoid the \"Variable might not have been initialized\" error in Java?
String s=null; or St
It's really depends what you're doing in your program.
"" (empty string) is connected only with String and it's safer than null. When you call methods from String class for example: replaceAll(), indexOf() the program will work correctly but when you have null, you have NullPointerException all time when you're calling method on it.
Consider if string empty value in your application is not something bad to you, then choose str="".
Notice that very often is better when NullPointerException is thrown because we know about an invalid state in our application, so when you want know about this set String to null by default.