int的错误无法解除引用? [英] Error of int cannot be dereferenced?
本文介绍了int的错误无法解除引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的构造函数出错了,我不知道如何修复?我是java的初学者。这是我试图学习的示例练习:
I am getting an error with this constructor, and i have no idea how to fix? I am a beginner at java. This is from an example exercise that i was trying to learn:
/**
* Create an array of size n and store a copy of the contents of the
* input argument
* @param intArray array of elements to copy
*/
public IntArray11(int[] intArray)
{
int i = 0;
String [] Array = new String[intArray.length];
for(i=0; i<intArray.length; ++i)
{
Array[i] = intArray[i].toString();
}
}
推荐答案
int
不是java中的对象(它是原始的),所以你不能在它上面调用方法。
int
is not an object in java (it's a primitive), so you cannot invoke methods on it.
解决它的一个简单方法是使用
Integer.toString(intArray[i])
One simple way to solve it is using
Integer.toString(intArray[i])
这篇关于int的错误无法解除引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文