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
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)
+ 1
Set again flag=1 at next iteration
This works :
System.out.printf("%d \t \t %d", num[I], count);