Java – how to check whether the element in the int array is empty?
•
Java
Example:
I want to see if array [5] saves a value or is empty
Solution
Elements in the original array cannot be empty They are always initialized to something (usually 0, for int arrays, but depending on how you declare the array)
If you declare an array like this (for example):
int [] myArray ; myArray = new int[7] ;
Then all elements will default to 0
The alternative syntax for declaring arrays is
int[] myArray = { 12,7,32,15,113,7 };
The initial value of the array (size 7 in this case) is given in braces {}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码