Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class ArrayOps
- {
- /**
- This method goes through the array of integers identified by
- the only parameter, creating a new ArrayList from the array,
- eliminating duplicates from the original array.
- @param theArray, an array of integer
- @return the new ArrayList
- */
- public static ArrayList copyArray(int[] anArray)
- {
- ArrayList list = new ArrayList();
- for(int a : anArray){list.add(a);}
- for(int i = 0; i < list.size(); i++)
- {
- for(int j = i + 1; j < list.size(); j++)
- {
- if(list.get(i) == list.get(j)){list.remove(j); j--;}
- }
- }
- return list;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement