Reputation: 1
static ArrayAdapter<CharSequence> createFromResource(Context context, int textArrayResId, int textViewResId)
Can someone explain the syntax of ArrayAdapter<CharSequence>
?
Thanks
Upvotes: 0
Views: 139
Reputation: 4593
ArrayAdapter is a type declaration for the return value of that method. The bit with the angle brackets is a type declaration for Java generics. Read more about Java generics here:
http://download.oracle.com/javase/tutorial/java/generics/index.html
Upvotes: 1
Reputation: 245489
That would be a use of generics.
In simple, readable terms it says that you are going to receive an ArrayAdapter
of CharSequence
s from the call.
In not so simple terms, it means that you're constraining one or more members of the ArrayAdapter
type to be of type CharSequence
.
Upvotes: 3
Reputation: 1503479
That's generics. It's a way of saying that one type's API can be parameterized by one or more other types. It's saying that the return type is ArrayAdapter<T>
where T is CharSequence
in this particular case.
For a lot more information, see Angelika Langer's Java Generics FAQ. You might want to start with "What are Java generics?"
Upvotes: 6