import java.util.*;
import java.io.*;
public class search {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner x = null;
String k;
int c= 0;
try{
x =new Scanner( new BufferedReader (new FileReader("hh.txt")));
while(x.hasNext()){
k = x.next();
if(k.equals(args[1]))
{
c++;
}
}
}catch(Exception ex){
System.out.println(ex.toString());
}
System.out.println("The number of occurrence of String is "+c);
}
}
The Program throws a Exception can any one tell me how to handle it. java.lang.ArrayIndexOutOfBoundsException: 0 The number of occurrence of String is 0