Java Reference
In-Depth Information
One more point to be discussed is about comparing arrays and objects. Arrays consist of a
range of variables which can hold a range of variables. But there is a limitation with arrays.
Arrays can hold variables of the same data type. It can not hold variables of different data
types. for example array But the same is not true for objects. Objects can hold variables of
any mixed data types. There is no limitation whatsoever in this regard.
Figure 1.12: Difference between arrays and objects
To understand the difference between arrays and objects, please refer Figure 1.12. The ar-
ray 1 is an integer data type and so can hold only integer values. Array 2 is of string data
type and can hold only string values. But an object has no such restriction. It can hold in-
teger, string, Boolean or just any other data type. This indeed is a strong concept.
One of the goals of object oriented programming is to bridge the gap between relational
databases and the programming paradigm. As you can now understand, procedural pro-
gramming was not able to provide basic structures which could hold just any values of any
data type. In contrast a record in a database can contain values of any data type. This goal
has not been achieved yet; but object oriented programming is moving in that direction. If
you are able to create a class which can provide structure to its objects which are exactly
the same as that of a record in a database then you will have a true relationship between a
class and a table in the database. In that case, you just create an object and when you ask
the object to save data in a table then you do not need to do some extra processing to match
data structure of an object and that of a table in the database.
Search WWH ::




Custom Search