1import java.util.*;
2
3public class RemoveDuplicatesFromArrayList {
4
5 public static void main(String[] args) {
6 List<Integer> numbers = Arrays.asList(1,2,2,2,3,5);
7
8 System.out.println(numbers);
9
10 Set<Integer> hashSet = new LinkedHashSet(numbers);
11 ArrayList<Integer> removedDuplicates = new ArrayList(hashSet);
12
13 System.out.println(removedDuplicates);
14 }
15}
16
1String str1 = "ABCDABCD";
2String result1 = "";
3
4for (int a = 0; a <= str1.length()-1; a++) {
5if (result1.contains("" + str1.charAt(a))) {
6// charAt methodda you provide index number ve sana character olarak donuyor,
7// If the string result does not contains str.CharAt(i),
8// then we concate it to the result. if it does we will not
9 continue;
10}
11result1 += str1.charAt(a);
12}
13System.out.println(result1);