举个例子:
public class foo
{
public int[] func()
{
int arr[] = new int[3];
// here initialised the array
return arr;
}
}
Run Code Online (Sandbox Code Playgroud)
我对Java没有经验,但我知道一些C/C++.
是的,它完全没问题,因为垃圾收集是在没有对象的进一步引用时完成的.您还可以使用lengthinside(arr.length)或outside(例如aFoo.func().length)方法来查找数组大小.
| 归档时间: |
|
| 查看次数: |
124 次 |
| 最近记录: |