我只想问,是否可以在一个命令中使用相同的构造函数初始化更多对象?
代码示例:
Tile[] tiles = new Tile(5,5)[20];
Run Code Online (Sandbox Code Playgroud)
谢谢你的回复.
这是将已定义的int设置为null的最佳方法?
private int xy(){
int x = 5;
x = null; //-this is ERROR
return x;
}
Run Code Online (Sandbox Code Playgroud)
所以我选择这个
private int xy(){
Integer x = 5;
x = null; //-this is OK
return (int)x;
}
Run Code Online (Sandbox Code Playgroud)
然后我需要这样的东西:
if(xy() == null){
// do something
}
Run Code Online (Sandbox Code Playgroud)
我的第二个问题是否可以安全地将Integer转换为int?
谢谢你的回复.