Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to Android and while going through a tutorial on saving Activity state to a Bundle, I noticed that instead of accepting the more generic List interface, Bundle's put methods are expecting ArrayLists.


Bundle.putCharSequenceArrayList(key, value)
Bundle.putIntegerArrayList(key, value)
Bundle.putParcelableArrayList(key, value)
Bundle.putStringArrayList(key, value)

Most of us are familiar with item 52 of Effective Java suggesting that objects must be refered to by their interface, so I am wondering what was the reason behind this API decision.

Is ArrayList perhaps the preferred list implementation in Android?

share|improve this question
up vote 8 down vote accepted

Just a guess: Maybe Bundele-content must be be serializable and not every Lists implementation is serializable.

From sdk-doc public Bundle.Bundle (ClassLoader)

  Constructs a new, empty Bundle that uses a specific 
  ClassLoader for instantiating Parcelable and Serializable objects.
share|improve this answer
makes sense! i'll wait a while more in case someone has a definitive answer. – jramoyo Jul 24 '13 at 5:33
the more I go through the tutorial, the more this answer makes sense. so I am accepting it :-) – jramoyo Jul 24 '13 at 10:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.