Videos
Which Interfaces are Implemented by Arrays in Java?
What are the Three Types of Java?
What is the Knowledge Pass, and how does it work?
ALL objects in Java extend Object.
Therefore it is possible to be completely non-descriptive when you create the array by declaring it an array of Objects:
Object[] arr = new Object[6];
This code creates an array of objects of length 6.
So for instance, you could create an array where entries come in pairs of two. In this case, the first object is a String and the second is an Integer.
Object[] arr = new Object[6];
arr[0] = new String("First Pair");
arr[1] = new Integer(1);
arr[2] = new String("Second Pair");
arr[3] = new Integer(2);
arr[4] = new String("Third Pair");
arr[5] = new Integer(3);
Now if you want to actually figure out what these objects are then it will require a cast:
int x = (Integer)arr[1];
To add to the other answers, you can put whatever you want in an array of Objects. But if you wish to access any of methods or properties, not shared with Object, that a specific element has, then you have to down-cast it to the needed type as Java will recognise it as type Object - this is something you have to be careful with.
Example:
Object test[];
test = new Object[]{1, 2, "three", new Date()};
System.out.println( ( (Date)test[3] ).getMonth() );
// the above line will output '4', but there will be a compilation error
// if the cast (Date) is emitted