Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- public class Duplicate {
- public static void main(String[] args) {
- String[] ss = {"b", "b", "a", "a", "c", "c"};
- List<String> ls = new ArrayList<String>();
- for (int i = 0; i < ss.length; i++)
- ls.add(ss[i]);
- String prev = ls.iterator().next();
- List<String> ret = new ArrayList<String>();
- ret.add(prev);
- for (String e: ls) {
- if (!prev.equals(e)) ret.add(e);
- prev = e;
- }
- System.out.println(ret);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement