I am trying to filter my arrays by creating a new array and copying the array1[i] within the limits in another array I created.
I'm setting the arrayFiltered to null at the beginning and then I'm trying to populate it. However, the array stays null.
Do you guys have any clue why is that?
If I don't set it to null at the beginning, it works, but then my do-while loop does not work.
double lowerLimit, upperLimit;
ArrayContructor arrayFiltered = new ArrayContructor;
arrayFiltered = null;
System.out.print("\n\nEnter a lower limit for daily hire rate:");
lowerLimit = input.nextDouble();
System.out.print("Enter a upper limit for daily hire rate:");
upperLimit = input.nextDouble();
for (int j = 0; j < array1.length; j++)
if (array1[j] != null)
if (lowerLimit <= array1[j].getDailyRate() & array1[j].getDailyRate() <= upperLimit )
arrayFiltered[j] = array1[j];
if (arrayFiltered == null)
System.out.println("There are nothing within those limits");
while (arrayFiltered == null);