Bob Bob - 11 months ago 59
Java Question

How can I check if an array of unknown type is empty?

Say I have an Object which I know is an array. How can I find out if it contains any elements?

public void myMethod (Object o) {
if (o.getClass().isArray()) {
// how can I check if the array contains any elements?

Answer Source