Most of the necessary introduction to arrays is in the last section of Chapter 4, which shows how you define and initialize an array. Holding objects is the focus of this chapter, and an array is just one way to hold objects. But there are a number of other ways to hold objects, so what makes an array special?
Latest Thinking In Java Articles - Page 6
To summarize what we’ve seen so far, your first, most efficient choice to hold a group of objects should be an array, and you’re forced into this choice if you want to hold a group of primitives. In the remainder of the chapter we’ll look at the more general case, when you don’t know at the time you’re writing the program how many objects you’re going to need, or if you need a more sophisticated way to store your objects. Java provides four types of collection classes to solve this problem: Vector , BitSet , Stack , and Hashtable . Although compared to other languages that provide collections this is a fairly meager supply, you can nonetheless solve a surprising number of problems using these tools.
Polymorphism means “different forms.” In object-oriented programming, you have the same face (the common interface in the base class) and different forms using that face: the different versions of the dynamically-bound methods.
In Chapter 6 you saw how an object can be used as its own type or as an object of its base type. Taking an object handle and treating it as the handle of the base type is called upcasting because of the way inheritance trees are drawn with the base class at the top.
Latest Developer VideosMore...
Latest CodeGuru Developer Columns
Become more proficient on the usage of statements to control the flow of execution through a C++/CLI application.
Just by using a bit of code, you can find virtually any IP address and its "real" name.
Discover how to make your own text editor in Visual Basic.
Have you ever wanted to control your garage door from your smartphone? Here is your chance. Get your hands dirty with an Arduino Garage Door Controller.