-
Enhancement
-
Resolution: Fixed
-
P5
-
8, 11, 13, 15, 16, 17
SonarCloud actually found this:
Verify this is the index that was intended; it was already set before.
public byte[][] toByteArray() {
byte[][] result = new byte[nameStrings.length][];
for (int i = 0; i < nameStrings.length; i++) {
result[i] = new byte[nameStrings[i].length()]; // <-- here
result[i] = nameStrings[i].getBytes();
}
return result;
}
`getBytes()` returns the `byte[]` array, there is no need to allocate the array before it.
Verify this is the index that was intended; it was already set before.
public byte[][] toByteArray() {
byte[][] result = new byte[nameStrings.length][];
for (int i = 0; i < nameStrings.length; i++) {
result[i] = new byte[nameStrings[i].length()]; // <-- here
result[i] = nameStrings[i].getBytes();
}
return result;
}
`getBytes()` returns the `byte[]` array, there is no need to allocate the array before it.