-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_methods.java
More file actions
31 lines (26 loc) · 944 Bytes
/
Copy patharray_methods.java
File metadata and controls
31 lines (26 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.ArrayList;
public class array_methods {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<String> cars = new ArrayList<String>(); // create an array list object
cars.add("volvo");
cars.add("Bus");
cars.add("car");
cars.add("ford");
System.out.println(cars);
System.out.println("**********ACESS AN ELEMENT********");
System.out.println(cars.get(0));
System.out.println("**********change an item with set********");
cars.set(1,"abc");
System.out.println(cars.get(1));
System.out.println("**********Remove the eklement********");
System.out.println(cars.get(2));
cars.remove(2);
System.out.println("********array list size********");
System.out.println(cars.size());
System.out.println("********loops in Array*****");
for (int i = 0; i < cars.size(); i++) {
System.out.println(cars.get(i));
}
}
}