I am getting the below Findbugs error for my code,
Invocation of toString on <<Package Path>>
The code invokes toString on an array, which will generate a fairly useless
result such as [C@16f0472. Consider using Arrays.toString to convert the
array into a readable String that gives the contents of the array.
See Programming Puzzlers, chapter 3, puzzle 12.
Code:
logger.info("Adding information"+ Employee.getName()+ " "+
employeeForm.getQuestionAndAnswers());
Please let me know what is the error.
toString(int[]) method returns a string representation of the contents of the specified int array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).
The three methods demonstrated for getting a String out of these three types of arrays are (1) simple Object. toString() on each array (implicitly in case of null array to avoid the dreaded NullPointerException), (2) Arrays. toString(Object[]) , and (3) Arrays. deepToString(Object[]) .
As it says, doing
myArray.toString()
will generate something useless like java.lang.int[]@45345262
you'd want to use
Arrays.toString(myArray);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With