Posts

Showing posts with the label remove duplicate elements from array

Remove Duplicate Elements from an Integer Array in Java

Write a program in Java to remove all the duplicate elements in a one-dimensional array. The details of the class, its variables and member functions are given below: Class name : Remove Data members/instance variables : a[]: integer array to store the elements n: to store the size of the array Methods : Remove(int m): parameterized constructor to store n = m void input(): to enter the elements in the array void duplicate(): to remove all the duplicate elements from the array void display(): to display the final array Also write the main() method to create an object of the class and call the methods accordingly to enable the task. import java.util.Scanner; class Remove{     int a[];     int n;     public Remove(int m){         n = m;         a = new int[n];     }     public void input(){         Scanner in = new Scanner(System.in);         System.out.println...