Each sentence begins with a space. Gettin a null pointer exception at line 55. Plez help.
import java.io.*; public class sent5 { String temp = ""; String x; String x1; // to store each word of sentence String c; int l; // length of string int i; int l1; // length of sentence int c1; int k = 0; // array variable public void test() throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("ENTER SENTENCE"); x = br.readLine(); x += " "; l = x.length(); for (i = 0; i < l; i++) { if ((x.charAt(i) != '.') && (x.charAt(i + 1) != ' ')) c += x.charAt(i); else sent(c); } } public void sent(String c) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); l1 = c.length(); for (i = 0; i < l1; i++) { if (x.charAt(i) == ' ') c1++; } String v[] = new String[c1]; for (i = 0; i < l1; i++) { if (c.charAt(i) != ' ') x1 += c.charAt(i); else { v[k] = x1; k++; x1 = null; } } for (int i = 0; i < c1 - 1; i++) { for (int j = 0; j < c1 - i - 1; j++) { if (v[j].compareToIgnoreCase(v[j + 1]) > 0) { temp = v[j]; v[j] = v[j + 1]; v[j + 1] = temp; } } } // print } public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); sent5 o1 = new sent5(); o1.test(); } }