I mean if I have an array of integers int integers[] = {1,2,3,4,5} and an Object array that holds only integer Object objects[] = {5,4,3,2,1}
How can I match the object array to the integer array?
IT IS AN EXAMPLE, I mean that if the Object array contains strings and I save it in a String[] array, it allows me, if it has only characters I can save it in a char[] and so on with that logic.
It cannot be done directly.
Imagine you can do:
Okay, it doesn't look like anything illegal was done. But what if then:
What's up?
The two lines just above compile, but cause an error. Java doesn't like this, and wants if you do a "cast" to a subclass you do an explicit cast. Therefore, direct conversion cannot be done.
Solution: Create a new array of the target type, and iterate through the original array assigning the values.