I'm new to java and I have a doubt about what to do to check if a space in an array of integers does not have an assigned value. What I want to do is a method that receives an int array and returns the same but without the possible empty spaces of the array that I entered as a parameter, thus returning only the numbers in the parameter array.
You must first use the Java Wrapper classes (Integer instead of int). then you can use java 8 functional programming:
This method will return the list of the array without null values.
Hope this can help you
An array in java is automatically filled with the default value of the variable type.
In the case of an array of int, this when initialized, is filled with zeros.
To solve your problem, you should make a loop like the following: