Simple solution: Sort the array. Then all duplicates are next to each other, and can be located, counted, and printed in a single pass.
Hint: Java has a sort method for arrays built in ...
But do yourself a favour and indent your code - it's a lot more readable that way.
[edit]
Just for kicks, I had 2 minutes to spare, so I tried this exercise in C# ...
private Dictionary<int, IEnumerable<int>> GetMultiples(int[] arr)
{
Array.Sort(arr);
Dictionary<int, IEnumerable<int>> counts = new Dictionary<int, IEnumerable<int>>();
for (int i = 0; i < arr.Length; i++)
{
int val = arr[i];
counts[val] = arr.Where(x => x != val && x % val == 0);
}
return counts;
}
...
int[] arr = { 2, 3, 6, 10 };
Dictionary<int, IEnumerable<int>> counts = GetMultiples(arr);
foreach (int key in counts.Keys)
{
IEnumerable<int> values = counts[key];
int count = values.Count();
if (count == 0) Console.WriteLine($"{key} has no multiples");
else
{
Console.WriteLine($"{key} has {count} multiples: {string.Join(",", values.Select(n => n.ToString()))}");
}
}
2 has 2 multiples: 6,10
3 has 1 multiples: 6
6 has no multiples
10 has no multiples
You can't use that code directly in Java, but at least it shows you it's possible ...
[/edit]