In Java, what is the difference and best way to do?
Integer x = null; // x later assign some value. Integer y; // y later initialize and use it.
Its better to not set it to null, otherwise you can by accident use it and cause NPE. Compiler wont help you with compile error. Only set to null if you want to have logic like if ( x != null ) { /use it/ }