Help with arrays
Ok, here's what I have so far:
publicclass Duplication{
/**
* Method main
*
*
* @param args
*
*/
publicstaticvoid main(String[] args){
//int array[] = {32, 27, 64, 18, 18};
int[] array =newint[5];
array[0] = 14;
array[1] = 13;
array[2] = 95;
array[3] = 24;
array[4] = 24;
System.out.printf("%s%8s\n","Index","Value");
for(int counter = 0; counter < array.length; counter++){
if(array[counter] == array[counter + 1])
System.out.printf("%4d%8d\n", counter,"0");
else
System.out.printf("%4d%8d\n", counter, array[counter]);
}
}
}
My problem is this, my job was to input 5 numbers, any numbers between 10 and 100 and display it. However, if the nubers repeat, then return nothing or just the previous number. So the problem with this code is that i get:
--Configuration: testing - JDK version 1.6.0 <Default> - <Default>--
IndexValue
014
113
295
3Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.String
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:3992)
at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2708)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2660)
at java.util.Formatter.format(Formatter.java:2432)
at java.io.PrintStream.format(PrintStream.java:920)
at java.io.PrintStream.printf(PrintStream.java:821)
at Duplication.main(Duplication.java:44)
Process completed.
Can anybody help me please?

