Johnny Jazz
Johnny Jazz

Reputation: 1

Java Syntax Question

static ArrayAdapter<CharSequence> createFromResource(Context context, int textArrayResId, int textViewResId)

Can someone explain the syntax of ArrayAdapter<CharSequence>?

Thanks

Upvotes: 0

Views: 139

Answers (3)

Mike Yockey
Mike Yockey

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

Justin Niessner
Justin Niessner

Reputation: 245489

That would be a use of generics.

In simple, readable terms it says that you are going to receive an ArrayAdapter of CharSequences 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

Jon Skeet
Jon Skeet

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

Related Questions