# create an empty list my_list = [] # add elements to the list using the append() method my_list.append(10) my_list.append(20) my_list.append(30) # display the list print(my_list)
// import the java.util package import java.util.Vector; // create a Vector object VectorIn this example, we create an empty Vector object and use the add() method to add elements to it. We then display the elements of the Vector using the System.out.println() method. The add() method belongs to the java.util package.vector = new Vector (); // add elements to the Vector using the add() method vector.add(10); vector.add(20); vector.add(30); // display the Vector System.out.println(vector);