Skip to content

Commit 1d5cf20

Browse files
authored
Create ArrList.java
1 parent 6ebd896 commit 1d5cf20

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Lists/ArrList.java

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.List;
2+
import java.util.ArrayList;
3+
public class ArrList{
4+
public static void main(String [] args)
5+
{
6+
7+
User me = new User();
8+
me.setFirstName("Omar");
9+
me.setLastName("Belkady");
10+
11+
12+
User you = new User();
13+
you.setFirstName("Nour”);
14+
you.setLastName("Abouham");
15+
16+
//Remember uppercase User is the type. The you is the name of the
17+
//variable
18+
//When working with lists where we have to put a generic type
19+
//We can use the custom type. This is a custom type of type User
20+
List<User> users = new ArrayList<User>();
21+
//To append I use .add and I add the custom type user
22+
users.add(you);
23+
users.add(me);
24+
25+
//To access
26+
System.out.println(users.get(1).getFullName());//1=me
27+
28+
}
29+
}

0 commit comments

Comments
 (0)