0

I was reading this answer, and now got confused about the normal array declaration and this piece of code used to create arrays for generic classes:

Gen<?> gens[] = new Gen<?>[10];

What does this do exactly, and how it is different from the normal array declaration?

1

2 Answers 2

4

I'm only a beginner so I might be wrong, but this is my take on the declaration you've written:

Gen is a generic class, like a template. The question mark signifies a wildcard. Therefore, you have initialized an array of 10 Gen templates that may be configured with any type of object.

Sign up to request clarification or add additional context in comments.

Comments

2

it is an array with 10 places that holds a generic class of type Gen that is a generic class of any object

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.