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

Can someone explain the syntax of ArrayAdapter<CharSequence>?

Thanks

3 Answers 3

6

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?"

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

Comments

3

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.

Comments

1

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

2 Comments

ArrayAdapter isn't a class declaration... it's the return type of the createFromResource method...
You are of course, correct. Bad terminology is bad terminology. Corrected.

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.