1

I'm new to java. Please let me know how to verify if variable type is an array in Java languge.

2 Answers 2

7

With any object, you can do this:

Class clazz = myObject.getClass();

if( clazz.isArray() ) {
    // ... array specific stuff.
}
Sign up to request clarification or add additional context in comments.

Comments

1

Any type that is suffixed by [] is an array type.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.