I need to have the user input a size of the array in the variable n and then create a single dimension array of Strings and have it filled with sentences. I also need to make sure that each sentence ends with a full stop (a . ). so here's what I have:
import java.util.*;
class encryption{
        void main(){
                Scanner sc=new Scanner(System.in);
                System.out.println("Enter the number of sentences to be encrypted");
                int n=sc.nextInt();
                String[] a=new String[n];
                System.out.println("Enter the sentences");
                for(int i=0; i<n; i++){
                    a[i]=sc.nextLine();
                    while(a[i].charAt(a[i].length()-1)!='.'){
                        a[i]=sc.nextLine();                                                
                    }
                    if(i%2==0){
                        a[i]=rev(a[i]);
                    }
                    else{
                        a[i]=frwd(a[i]);
                    }
                }
                for(int i=0; i<n; i++){
                    System.out.println(a[i]);
                }
            }
After the inputs, I will work on the Strings using the functions rev(...) and frwd(...), and then print the changed strings. 
It compiles fine, however upon execution, the first line in the first for loop a[i]=sc.nextLine(); doesn't seem work. It gives me a straight  indexOutOfBounds error meaning it goes straight onto the while loop.
How can I make it accept input there?
 
    