0

I ran across this function definition :

public Collection<Class<? extends SomeClass>> someFunc();

What does the Class<? part mean? Coming from C++, it looks like templates, but I'm not quite sure if this is the case, since there are constructs in Java that look like C++, but aren't quite the same. In either case, I'd like to know what this means and how it's used.

I looked up what this meant, but I couldn't find anything relevant (perhaps there's a special name for this operator that I'm not aware of) - looking up "Class<? in Java" returned results similar to "what is a class in java". I'm fairly new to Java programming, so my apologies if this is something basic.

Thanks in advance.

aspen100
  • 965
  • 11
  • 22

1 Answers1

3

What you have come across is Java generics. Generics are Java's parallel to C++ templates. The question mark symbol ? stands for a wildcard.

To learn more, you can look for these terms or directly go to Oracle tutorial: https://docs.oracle.com/javase/tutorial/java/generics/

marcelv3612
  • 663
  • 4
  • 10