hello everyone, can someone help me with my problem? Our java teacher tell us to do this " Create a program that does not store the whole input in the memory. " and this is the program i have. But i don't know what to change to not store the input in the memory. Thank you all for you futur awnser.

import java.io.IOException;
import java.util.Scanner;


public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int actual_number = -1, sum=0, counter=0;


while (actual_number!=0)
{
System.out.println("Enter a number:");
actual_number=sc.nextInt();
sc.nextLine();
System.out.println("the entered number was : " + actual_number);

if (actual_number==0) break;

sum += actual_number;
counter++;

}
System.out.println("So the program can start : ");
System.out.println("the computed average is : " + (float)(sum/counter) );
System.out.println("end of the program" );
sc.close();


}
}