What does the following piece of code do?
Posted: Wed Jul 13, 2022 6:15 pm
for (int i = 0; i < arr.length-1; i++)
{
for (int j = i+1; j < arr.length; j++)
{
if( (arr.equals(arr[j])) && (i != j) )
{
System.out.println(arr);
}
}
}
a) Print the duplicate elements in the array
b) Print the element with maximum frequency
c) Print the unique elements in the array
d) Prints the element with minimum frequnecy
{
for (int j = i+1; j < arr.length; j++)
{
if( (arr.equals(arr[j])) && (i != j) )
{
System.out.println(arr);
}
}
}
a) Print the duplicate elements in the array
b) Print the element with maximum frequency
c) Print the unique elements in the array
d) Prints the element with minimum frequnecy