1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
-
-
- public final class StringDuplicateDeleter extends DuplicateDeleter<String> {
-
- public StringDuplicateDeleter(String[] array){
- super(array);
- }
-
- public String[] removeDuplicates(int maxNumberOfDuplications){
- String[] newArray=new String[100];
-
- int m=0;
- for(int i=0;i<array.length;i++)
- {
- int k=noOfOccurrence(array[i]);
- if(k<maxNumberOfDuplications)
- {
- newArray[m]=array[i];
-
- m++;
-
- }
- }
- String[] resultArray=new String[m];
- for(int i=0;i<m;i++)
- {
- resultArray[i]=newArray[i];
- }
- System.out.println(resultArray);
-
- return resultArray;
- }
-
- public int noOfOccurrence(String a)
- {
- int count=0;
- for(int i=0;i<array.length;i++)
- {
- if(array[i].equals(a))
- {
- count++;
- }
- }
-
- return count;
-
- }
-
- public String[] removeDuplicatesExactly(int exactNumberOfDuplications){
- String[] newArray=new String[100];
-
- int m=0;
- for(int i=0;i<array.length;i++)
- {
- int k=noOfOccurrence(array[i]);
- if(k!=exactNumberOfDuplications)
- {
- newArray[m]=array[i];
-
- m++;
-
- }
- }
- String[] resultArray=new String[m];
- for(int i=0;i<m;i++)
- {
- resultArray[i]=newArray[i];
- }
- System.out.println(resultArray);
-
- return resultArray;
- }
-
- }
-
-
|