int 错误不能解除引用? [英] Error of int cannot be dereferenced?

查看:53
本文介绍了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 is not an object in java (it's a primitive),所以你不能调用它的方法.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆