How to print print the first and last numbers from the list do while loop

Take the System.out out of the loop

int w=-10;
System.out.println(w);
do {
    w++;    
} 
while (w<=2020);
System.out.println(w-1);

Leave a Comment