我有一个Vector
完整的long
s。
我希望能够始终调用getFirstElement()
Vector 然后执行一个动作,比如说addToOtherVector()
. 我希望能够不担心是否真的有一个值可以从我的原始向量返回。我想我可以通过这样覆盖来做到这addToOtherVector()
一点:
//Code to be called when my first vector is not empty
public void addToOtherVector(long s){
othervector.add(s);
}
//Code to be called when my first vector IS empty
public void addToOtherVector(something???){
//does nothing
}
但我不确定我需要做什么,因为它不会接受null
作为参数?
我这样做的原因是因为我不希望每次尝试检索时都检查向量的大小