3

The following code

    public static void main(String[] args) {
        fun(new Integer(1));
    }
    static void fun(Object ... a) {
        System.out.println(a.getClass());
    }

gives the output :-

class [Ljava.lang.Object;

What class is this?

3 Answers 3

7

An Object[] array.

To get the runtime type information:

a.getClass().isArray() -> true
a.getClass().getComponentType().getName() -> java.lang.Object
Sign up to request clarification or add additional context in comments.

Comments

6

according to the JVM specifications it is simply an array of java.lang.Object:

  • [ means a monodimensional array
  • LfullyQualifiedName; means a class, L; is just syntax

1 Comment

it is used only as delimiter, no special meaning; did you read the specifications?
1

This is how varargs (methods with a variable number of arguments) work in Java - the varargs argument will look like an array inside the method.

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.