My eYMethods class has 2 static methods the first one is writeUSB that fills my object array with my scanner and I want to stop creating object arrays if (sumMemory > 80) and delete the object that passed the condition. But when I do that, my second static method showDocs that I call in my main class points null cause example: (if I create 2 object arrays and the first one override the condition of sumMemory, the second object array waits from my getters some values so it points null ). How can I fix that?
package eymain;
public class eYMethods {
static int writeUSB(ekpaideytikoYliko usb[]) {
double sumMemory = 0 ;
int noOfObjects = 0;
for(int i = 0; i < usb.length; i++) {
System.out.println("Δωσε fileName : ");
String fileName = scannerUserInput.getString();
System.out.println("Δωσε minutes : ");
double minutes = scannerUserInput.getDouble();
System.out.println("Δωσε memorySpace");
double memorySpace = scannerUserInput.getDouble();
System.out.println();
ekpaideytikoYliko tempEkpaideytikoYliko = new ekpaideytikoYliko(fileName, minutes, memorySpace);
usb[i] = tempEkpaideytikoYliko;
noOfObjects++;
sumMemory += memorySpace;
if (sumMemory > 80) {
noOfObjects--;
System.out.println("OverLimit");
break;
}
}
System.out.println("sumMemory : " + sumMemory);
return noOfObjects;
}
static void showDocs(ekpaideytikoYliko usb[]) {
for(int i =0; i < usb.length; i++) {
System.out.println("fileName : " + usb[i].getFileName());
System.out.println("minutes : " + usb[i].getMinutes());
System.out.println("memorySpace : " + usb[i].getMemorySpace());
System.out.println();
}
}
}
ekpaideytikoYliko?