Do you need to solve the problem of finding the middle of the list in one pass when the number of elements is unknown in advance?
public static void main(String[] args) {
var in = "0 1 2 3 4";
var scan = new Scanner(in);
var midAddress = -1;
while(scan.hasNext()) {
midAddress++;
scan.next();
if (!scan.hasNext()) break;
scan.next();
}
System.out.println("Middle address: " + midAddress);
}