Write a program to sort an given array and remove duplicates in it with out using java API and print the sort order and the number of occurrence of duplicates.
RE: Write a program to sort an given array and remove ...
program for above question import java.util.*; 2: 3: class Name { 4: public static void main(String[] arguments) { 5: String names[] { Peter Patricia Hunter Sarah 6: Gabe Gina Rob John Zoey Tammy Robert 7: Sean Paschal Kathy Neleh Vecepia }; 8: System.out.println( The original order: ); 9: for (int i 0; i < names.length; i++)10: System.out.println(i + : + names[i]);11: Arrays.sort(names);12: System.out.println( The new order: );13: for (int i 0; i < names.length; i++)14: System.out.println(i + : + names[i]);15: }16: }
RE: Write a program to sort an given array and remove ...
String names[] { Peter Patricia Hunter Sarah Gabe Gina Rob John Zoey Tammy Robert Sean Paschal Kathy Neleh Vecepia Robert }; TreeSet set new TreeSet(Arrays.asList(names)); for (String name : set) System.out.println(name);
RE: Write a program to sort an given array and remove duplicates in it with out using java API and print the sort order and the number of occurrence of duplicates.
RE: Write a program to sort an given array and remove duplicates in it with out using java API and print the sort order and the number of occurrence of duplicates.
Sort the array and compare the adjacent elements if the adjacent elements are equal then there will be duplicates.