0

Guys Help me with this one.

I have an error in regards to the boolean being used, but Im confused what to do, I am new on Java and Im not Familiar on the error being stated on my compiler, Ill just want my program to display all the entered number on the array and print the occurrence of each. Example: arr[1,1,1,2,3,4,4,5,5,5] Sample Output: Value Occurence 1 3 2 1 3 1 4 2 5 3 https://code.sololearn.com/ct1I7c0z01p5/?ref=app

28th Oct 2020, 11:37 AM
Jan Patrick Urbano
Jan Patrick Urbano - avatar
2 Answers
+ 2
You can't directly use %d and such in System.out.print() You need to pass all of them to String.format() String.format("%d\t\t%d\n", num[i], count)
28th Oct 2020, 11:53 AM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘ä¹Ÿę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘ä¹Ÿę˜Æ - avatar
+ 1
Set again flag=1 at next iteration This works : System.out.printf("%d \t \t %d", num[I], count);
28th Oct 2020, 12:54 PM
Jayakrishna šŸ‡®šŸ‡³