Hi ,
Can anyone please explain the program below,
package regex;
import java.util.*;
public class ScanIn {
public static void main(String[] args) {
System.out.println("input:");
System.out.flush();
try{
Scanner s = new Scanner(System.in);
String token;
do{
token=s.findInLine(args[0]);
System.out.println("found "+token);
}while(token != null);
}
catch(Exception e){
e.printStackTrace();
System.out.println("scan exc");
}
}
}
with the following invocation and input :
java ScanIn "\d\d"
input : 1b2c335f456
the output is supposed to be:
found 33
found 45
found null
but iam getting an ArrayOutOfBoundsException at line 12, so my output is
found null
can anyone help me correct the problem. and also explain the program?
I dont understand what these lines in the program actually do,
Scanner s = new Scanner(System.in);
token=s.findInLine(args[0]);