theJava
theJava

Reputation: 15044

Are all data types a specific type of an Object?

Are all data types a specific type of an Object?

If I call Array a type of Object, then what would I call the values inside the Array?

Upvotes: 0

Views: 64

Answers (1)

Felix Kling
Felix Kling

Reputation: 817030

That depends on the programming language. For example there exist no objects in C. Here, an array is a continuous space in memory.

In PHP, arrays are not objects either, but they are implemented as hash maps.

In Java, arrays are not objects, but they can contain objects. On the other side, ArrayLists are objects and can only contain objects. Edit: See comment.

In JavaScript, everything but the primitive types are objects, also arrays.


You have to be careful to distinguish between the terminology of the language and the general data structure.

Upvotes: 2

Related Questions