In this video, Doug Winnie shows how to change elements in an array, and introduces the ArrayList. The ArrayList is a more flexible type of collection that allows you to add elements with the add method, and remove elements with the remove method.
- [Narrator] When you create a collection of values…you will undoubtedly want to change them at some point.…However, there are some limitations with arrays…that can make them difficult to work with.…Once you define the number of elements of an array…it's fixed and it can't be resized.…You can change the elements within them,…but that's about it.…Let's go ahead and create a new array by saying it's…going to be a string array, called my array.…We'll set it equal to a new string array,…and we'll put in some names.…
Doug,…Mike,…Janet,…and Matt.…Then we can output this to the console.…We'll do that using a for loop.…for (String element : myArray)…Since we're only doing one line,…we can put this all in a single row.…System.out.println(element)…Go ahead and run the program…to see the output from the loop.…
When you create an array, you can't create…new elements after it's created.…The array is limited to the initial number…you define at the beginning.…We can change one of the elements, however.…We can do that by accessing the array object,…
- The history of Java
- Setting up your development environment
- Working with values and variables
- Using methods and functions
- Capturing user input
- Creating conditional tests
- Using loops
- Creating and changing arrays
- Object-oriented programming in Java
- Defining permissions
- Extending classes
Skill Level Beginner
Computer Science Principles: The Internetwith Doug Winnie59m 30s Beginner
Java Essential Training for Studentswith Peggy Fisher3h 6m Intermediate
1. Intro to Java
2. Define Actions Using Code
3. Repeat Actions and Test for Conditions
4. Object-Oriented Programming Basics
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.