我是java新手。我需要将原始类型值作为函数调用中的引用传递。我不想从函数返回 i 值,因为它已经返回了一些对象。
for (int i = 0; i < objects.size();) {
// here it should fetch that object based on i manipulated in function
Object obj = objects.get(i)
Object node = someFunction(session,obj,i);
// push node in nodes array
}
public Object someFunction(Session session,Object obj,int i){
//manipulate i value based on condition
if(true){
i = i + 1;
}else{
i = i + 2;
}
}
当 JAVA 在函数调用中使用按值传递时,我如何实现这一点?
桃花长相依
阿晨1998
慕的地6264312
相关分类