here is java code using arrays
java·@mehram·
0.000 HBDhere is java code using arrays
import java.util.Scanner; public class bhatti { public static void main(String[] args) { Scanner input = new Scanner(System.in); int array[] = new int[10]; System.out.println("enter values you want to store in array: "); for (int i = 0; i < array.length; i++) { System.out.println("array[" + i + "]"); array[i] = input.nextInt(); if (array[i] > 9) { System.out.println("ERROR, array should be less than or equal to 9"); return; } } int i = 0; int newarray; int count; while (i < array.length) { newarray = array[i]; count = 0; for (; i < array.length && newarray == array[i]; i++, count++) ; System.out.println("array[" + count + "] " + newarray); } } }