This line of code gives the following warning:
short[] sh = null;
for (int i = 0, n = b.length; i < n; i++) {
sh[i] = 0;
}
warning: The variable sh can only be null at this location.
short[] sh;
for (int i = 0, n = b.length; i < n; i++) {
sh[i] = 0;
}
And, this code gives the following warning:
warning: The local variable sh may not have been initialized.
This is because you need to initialize the array. Try this:
If you don’t initialize, you will get those warnings, and will get
NullPointerExceptionif you run it.