Horje
String remove duplicate in java Code Example
String remove duplicate in java
String str1 = "ABCDABCD";
String result1 = "";

for (int a = 0; a <= str1.length()-1; a++) {
if (result1.contains("" + str1.charAt(a))) { 
// charAt methodda you provide index number ve sana character olarak donuyor,
// If the string result does not contains str.CharAt(i), 
// then we concate it to the result. if it does we will not
   continue;
}
result1 += str1.charAt(a);
}
System.out.println(result1);
java remove duplicates
import java.util.*;

public class RemoveDuplicatesFromArrayList {

    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1,2,2,2,3,5);

        System.out.println(numbers);

        Set<Integer> hashSet = new LinkedHashSet(numbers);
        ArrayList<Integer> removedDuplicates = new ArrayList(hashSet);

        System.out.println(removedDuplicates);
    }
}
Source: devqa.io




Java

Related
get current unix timestamp java Code Example get current unix timestamp java Code Example
copy to clipboard android studio Code Example copy to clipboard android studio Code Example
foreach java Code Example foreach java Code Example
how to reset jframe java swing Code Example how to reset jframe java swing Code Example
all devisor of a number java Code Example all devisor of a number java Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6