I have a byte[] and a short[] used for the same thing.
I want to switch from using the byte[] and short[] based on the maximum value needed, which changes occasionally.
My idea is to have an Object that is swapped between referencing the byte[] or the short[] as needed.
The part I can't figure out is casting the Object to the array type its referencing. I tried this to alter the contents of the array the object is referencing:
((array.getClass())(array))[pos] = ...
but it just says "the result of getClass() is unused" (aka it isnt trying to cast the Object with the result like i want it to)