I was trying to convert the below C code to Java. I am getting the below exception while doing so. What am I doing wrong here? Please advice.
Exception in thread "main" java.util.IllegalFormatConversionException: x != java.lang.String
at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
at java.util.Formatter$FormatSpecifier.print(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.lang.String.format(Unknown Source)
at com.kube.rfidscannertest.MainScannerTest.printEpc(MainScannerTest.java:68)
at com.kube.rfidscannertest.MainScannerTest.main(MainScannerTest.java:42)
Below is the C code.
printf("%04X", (((epc[i] & 0xFF00) >> 8) | ((epc[i] & 0xFF) << 8)));
Below is how I am trying to covert it into Java.
String.format("%04X ", Integer.toHexString((((data[i] & 0xFF00) >> 8) | ((data[i] & 0xFF) << 8))).replace(' ', '0')).concat(strData);
Please note that epc and data are integer arrays.