8.9 ArrayList

Hello, welcome to this new course in this course, let’s learn. Lists, what lists. Lists are ... used to store. And access data. As we saw with the tables, but between the lists and ... the tables, there is a difference. The advantages of the array is that it is possible to manage several values of the same ... type in the same variable Instead of declaring separate variables for each value But there are ... inappropriate Once an array has been defined on a number of dimensions It is accessed difficult to change ... throughout the program. But unlike the table Arrayalist can automatically add their capabilities When you add where ... delete items, that’s why we also call them. Dynamic Table I will start by showing you how. Declare ... a List how to add elements? How to see the elements that are? Also inside to be able to use the .. . ArrayList collection First you have to import. The java.util package Performs, its ArrayList We will give a name. maList Va ... are equal. new Arrayalist Semicolon You’re going to have a red here, we’re going to put the guy. The type represents the ... type of items that will be in the list for example, you can put. Integer Character Chains and ... other we will put a string of which String. and there to add Elements to our list ... just make maList the name Point and there you had a lot of method So we have ... A method add adAll over time, we will see the different method Who there is in our ... list To put An element you must use the method add we will put for example the name of a person ... so Peter point-comma Multiple element Steve John et cetera To add an element to our List You must use the ... method add() Now to display All elements in the console you simply need And there, we will concatenate ... with The name so maList as the program. In our console we have all the names Peter Steve and John ... If you want to recover a particular item you just need to put maList get this is a method. Which allows ... to return the item to the position. From the index of the list, we will put the index. That we want the element putting ... 2 for example and there to display element 2, we will copy this line, we will concatenate. Here, we compile ... our program. In the console, we have element. 2 which is John Why John surely you had to tell yourself. We ... must count 1 2, but in a list as in a table, we always start with 0 So first element ... Be at index 0. The second has index 1 and so on. Now, if you want to remove, we’ll.... use another method. maList Point remove the remove method allows to Remove an element in our list you must indicate ... the index we want to remove