Java中没有“out”或“ref”参数(我可能错了,因为我在3年内没有碰到Java)。我想创建类,如MyInteger,MyFloat和MyDouble,被用作out参数。有没有办法将它们组合成一个泛型类?对于MyInteger类用作输出参数的自定义编号类
示例代码:
public class MyInteger
{
private int value = 0;
public int getValue(){ return value;}
public void setValue(int newValue) {value = newValue;}
}
编辑:
如何使用MyInteger类:
public boolean aMethod(int input, MyInteger output)
{
boolean status = true;
//calculation here;
//set status to false if anything wrong;
//if nothing wrong do this: output.setValue(newValue);
return status;
}
编辑2:
什么我问的是我希望我可以将MyInteger,MyFloat ......合并为一个通用类。
你是问有关调用通过JDBC存储的过程与输出参数? – Kal 2011-04-27 14:14:06
您是否重新创建类似http://download.oracle.com/javase/6/docs/api/java/lang/Integer.html的包装类? – 2011-04-27 14:16:25
我仍然不明白你为什么需要这个功能。你的意思是出于/ ref究竟是什么意思? – 2011-04-27 14:22:57