"Swift Basics" was retired on May 31, 2020.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
An arrays length is immutable. If you want to add or remove, you need to declare a new array and copy into it. Don't worry you won't be doing this too much.
Learn More
Example ArrayList code
// This is coming from the Java Collection Framework
import java.util.List;
import java.util.ArrayList;
// This is using Generic syntax, we'll get to it...
List<String> friends = new ArrayList<>();
friends.add("Ben"); // adds "Ben" to the friends list
friends.size(); // returns 1
friends.contains("Ben"); // returns true
friends.remove("Ben");
friends.size() // returns 0
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up