Ask Question

g what does the following piece of code do a) Print the duplicate elements in the array b) Print the element with maximum frequency c) Print the unique elements in the array d) None of the mentioned

+5
Answers (1)
  1. 17 October, 15:09
    0
    a) Print the duplicate elements in the array

    Explanation:

    I found this code:

    This is two for cycle, where we make a comparison among two variables i and j to print duplicate elements.

    for (int i=0; i < arr. length-1; i++)

    {

    for (int j = i+1; j < arr. length; j++)

    {

    if ((arr[i]. equals (arr[j])) && (i! = j))

    {

    System. out. println (arr[i])

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “g what does the following piece of code do a) Print the duplicate elements in the array b) Print the element with maximum frequency c) ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers