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:
<
You code tries to call the toString() method of an int
value. In Java, int
is a primitive type and has no methods. Change the line:
Array[i] = intArray[i].toString();
to
Array[i] = String.valueOf(intArray[i]);
and the code should run. By the way, you should use lowerCamelCase for variables and fields.
Edit: For what it's worth, String.valueOf(int) is a bit faster than Integer.toString(int) on my system (Java 1.7).