public class frequencyinarray {
public static void main(String[] args) {
int a[] = new int[] { 1, 2, 8, 3, 2, 4, 4, 5 };
int t[] = new int[a.length];
int visited = -1;
for (int i = 0; i < a.length; i++) {
int count = 1;
for (int j = i + 1; j < a.length; j++) {
if (a[i] == a[j]) {
count++;
t[j] = visited;
}
}
if (t[i] != visited) {
t[i] = count;
}
}
for (int i = 0; i < a.length; i++) {
if (t[i] != visited) {
System.out.println(a[i] + " " + t[i]);
}
}
}
package com.dain.logics;
public class frequencyinarray { public static void main(String[] args) { int a[] = new int[] { 1, 2, 8, 3, 2, 4, 4, 5 }; int t[] = new int[a.length]; int visited = -1; for (int i = 0; i < a.length; i++) { int count = 1; for (int j = i + 1; j < a.length; j++) {
}