|
|
@ -5,6 +5,8 @@
|
|
|
|
package com.calebfontenot.lab5_calebfontenot;
|
|
|
|
package com.calebfontenot.lab5_calebfontenot;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -42,8 +44,40 @@ public class Person {
|
|
|
|
return "Person{" + "name=" + name + '}';
|
|
|
|
return "Person{" + "name=" + name + '}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void checkArrayList() {
|
|
|
|
|
|
|
|
Integer[] arr = {3, 1, 2, 3, 6, 3, 4, 6, 3};
|
|
|
|
|
|
|
|
ArrayList<Integer> list =new ArrayList<Integer>(Arrays.asList(arr));
|
|
|
|
|
|
|
|
System.out.println(list);
|
|
|
|
|
|
|
|
Object[] arr3 = list.toArray();
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
|
|
|
|
System.out.print(arr3[i] + " ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("max is " + Collections.max(list));
|
|
|
|
|
|
|
|
System.out.println();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void ArrayListGeneric()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static ArrayList<Integer> removeDuplicate(ArrayList<Integer> list) {
|
|
|
|
|
|
|
|
//list.contains();
|
|
|
|
|
|
|
|
//list.remove();
|
|
|
|
|
|
|
|
System.out.println(list);
|
|
|
|
|
|
|
|
ArrayList<Integer> newList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
|
|
|
|
if (!newList.contains(list.get(i))) {
|
|
|
|
|
|
|
|
newList.add(list.get(i));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return newList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args)
|
|
|
|
public static void main(String[] args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Integer[] arr = {3, 1, 2, 3, 6, 3, 4, 6, 3};
|
|
|
|
|
|
|
|
ArrayList<Integer> list2 =new ArrayList<>(Arrays.asList(arr));
|
|
|
|
|
|
|
|
System.out.println(removeDuplicate(list2));
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList list = new ArrayList();
|
|
|
|
ArrayList list = new ArrayList();
|
|
|
|
list.add(new Person("John Wayne", "123 Sunny Dr. Santa Barabara, 90611", "922-337-3231", "jw@gmail.com"));
|
|
|
|
list.add(new Person("John Wayne", "123 Sunny Dr. Santa Barabara, 90611", "922-337-3231", "jw@gmail.com"));
|
|
|
|
list.add(new Date());
|
|
|
|
list.add(new Date());
|
|
|
|