here is java code using arrays

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@mehram·
0.000 HBD
here 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);

		}

	}
}
👍 , , , , , , , , , , , ,