+ 8
I want to know ,the different between 'array' and 'object' and how to use them?
5 Answers
+ 2
array is an object and when you instantiate a new object (for example person) you put new keyword at begin. Arrays in some languages are yet declared from syntax and have some methods inside (length for example).
+ 7
an object is something with attributes. an array is a data structure used to store stuff.
example. you can have multiple objects with similar types of attributes all stored in an array for later use.
//pseudocode
class Person
//attributes
name
age
birthplace
//create a few instances of Person
new Person = myPerson
new Person = myOtherPerson
//once you set their attributes you can store in an array, although keep in mind some languages need you to be precise on what is being stored in the array... int or string. in this case we are storing Person.
//the number within the braces is the index. sometimes we may have to use predefined functions to resize our array otherwise we get a seg fault or a runtime error.
new Array = Person myArray []
myArray[0] = myPerson
myArray[1] = myOtherPerson
hope this helps!
+ 4
an array is a special type of object
an array uses no's to access its elements
while object uses names to access its eleme
+ 3
Thank you very much, Jesus Chavez, Afzaal Arif and Antonio Daniele Mu!
+ 1
Very helpful comments