I am working with arrays in Java and I have got a question. I know that an array in Java is a collection of similar data types, as shown below:
int[] x = new int[]{1,2,3};
The above declaration can be read as an Integer
array which is a collection of integer types.
Consider this:
Object[] x = new Object[]{1,2,3,"srk"};
Here, can I say that the above is an array which is a collection of dis-similar data types, or is it an Object
array of similar data types, i.e. objects?
I am muddled and skeptical about this. In Java, is it possible to create an array or any sort of collection which can hold different data types?