Isn't Android's Bundle functionally equivalent with a Map ?
Isn't Android's Bundle functionally equivalent with a Map ?
No, Android's Bundle
is not functionally equivalent to a Map
. While both are used to store key-value pairs, there are several important differences:
A Map
can have keys of any type, while a Bundle
requires String
keys[1].
A Bundle
implements Parcelable
, which is important for Android IPC (Inter-Process Communication). It allows Bundles
to be used as service parameters and attached to Intents
or passed into Activities
. In contrast, Map
is an interface and does not extend Parcelable
[1].
A Bundle
is optimized for storing and retrieving primitive types and String
values efficiently. It uses a more compact binary format compared to Map
[2].
**Bundle
provides convenience methods like getInt()
, getString()
, etc. to retrieve values of specific types, while a `Map...
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào