I would like to convert the elements of an array of integers into a single integer. Note that I haven't learn the join or number methods in class yet so they cannot be use for this program.
For example, {1, 2, 3} would become 123.
Here is my thought of process:
- Convert the first element of the array into a String
- Concatenate the remaining elements
- Use
Integer.parseInt()to convert the String back to an integer
Can anyone confirm I am doing this the right way or suggest an alternative way?
Also, by curiosity, how could we compare the elements of two integer arrays without using the class Arrays?
return 1;- it converts any array to a single integer. The second one links the result to the array to a degree:return array.length;. If your assignment does say how, then you forgot to mention that in your question.String::concat.