Is String a primitive or an Object in Android or Java?

Krishna Prasad picture Krishna Prasad · Jan 23, 2013 · Viewed 42.9k times · Source

In the Android API http://developer.android.com/guide/topics/data/data-storage.html#pref

It says:

Shared Preference allows you to save and retrieve persistent key-value pairs of primitive data types. You can use SharedPreferences to save any primitive data: booleans, floats, ints, longs, and strings.

Is String a primitive data type or an Object?

Answer

Narendra Pathai picture Narendra Pathai · Jan 23, 2013

Straight from JLS:

A string literal is a reference to an instance of class String

So no it is not a primitive.