Return empty Vector collection instead of null
问题 I have a function that returns a Vector and in case of an error, I want to return an empty Vector which can be checked using Collections.isEmpty by the calling method. But I am unable to find the way to do it as Collections provides Collections.emptyList functions for List, Maps, etc. but not for Vector and I am forced to return null by function which I want to avoid. How to achieve this? 回答1: You could return a new Vector<X>() , but a better solution would be to move away from Vector which