I am trying to create a String Revert Program where I enter Strings and they are stored in an Array -When the array is complete it prints the contents Backwards -If the user enters Quit the program stops and prints backwards without storing quit in the array
However my code doesn't print the last entry Im not sure why?
import java.util.*;
import java.io.*;
class StringRevert {
    public static void main(String[] args) {
        String buffer[];
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter Size: ");
        int num = scan.nextInt();
        buffer = new String[num];
        String read = scan.nextLine();
        for(int i=0; i<buffer.length; i++) {
            if(read.equals("quit")) {
                break;
            } else {
                buffer[i] = read;
            }
            read = scan.nextLine();
        }
        for(int k=buffer.length -1; k>=0; k--) {
            System.out.println(buffer[k]);
        }
    }
}
 
     
    