Game Development Reference
In-Depth Information
comma delimited List is passed at the end of the method parameter list, unless, as it is
in this case, it is the only parameter.
To show the .addCurrentCast() method that we are going to pass more than one
Actor object into the body of the method, we used the Actor... annotation, and I am go-
ing to name the (more than one) Actor objects variable actors . Inside of the body of the
.addCurrentCast() method we will call an .addAll() method off of the
CURRENT_CAST object using dot notation.
Inside of the .addAll() method we will nest another Java statement that will create
an Arrays object from the comma delimited List using the .asList() method called off
the Arrays class reference and pass the actors Actor... comma delimited list into that
method. This is all done using the following Java method construct:
public void addCurrentCast(Actor... actors) {
CURRENT_CAST. addAll ( Arrays. asList (actors) );
}
As you can see in Figure 10-4 , you will get a wavy red error highlighting under the
Arrays class, so use the Alt-Enter work process and have NetBeans write your import
java.util.Arrays; statement for you. Now we are ready to write the other two methods
relating to the CURRENT_CAST data store that will remove Actor objects from the
List<Actor> ArrayList<Actor> data store object, and one that will clear it out entirely
(reset it to being unused).
 
 
Search WWH ::




Custom Search