There's a third approach, of course, which is to do it all in one line:
Vector<DBRecord> aoEmsEntManList = oEmsEntDBClass.GetChildRecords("employee");
If you have to do it in two lines, then that's surely because you need to initialize inside a try block, but use the variable outside, the try block, right? In that case, if the method throws an exception, then the variable
won't be initialized, and so that's what the compiler is complaining about. In that case, you must use the "initialize to null" version. Otherwise, if the compiler doesn't force you to, then don't add the extra assignment; it just generates a little more bytecode for no reason. The
Java compiler is very good at figuring out whether or not this is needed.