Hello mcal.
Since you seem interested I will start with vectors. In the java.util package are many tools and data structures that one can use for a variety of problems. For most problems, I prefer to use vectors. To use vectors, make sure that you import the java.util.Vector class.
Okay, a vector is a dynamic data structure unlike arrays. That means that vectors will grow automatically as you need more space. When using vectors, it is good practice to use
generics. To define a vector object that can contain a variety of different objects we divine, lets say data, like this:
Vector<Object> data = new Vector<Object>();
This will create a empty vector of Object types. At the moment, data has no elements. To add an element, we use the Vector.add() method like this:
data.add("There is no spoon");
data.add(4400);
Note that 4400 is a literal and a primitive type. Java will box this automatically, that is turn the int into an Integer. To get the size of a vector, we use the Vector.size() method. To access an element of the vector, we use the Vector.get() method. In the code below we will print all the objects:
for (int i = 0; i < data.size(); i++){
System.out.println((data.get(i)).toString());
}
Are you following mcal?
