class Demo4
{
public static void main(String[] args)
{
fileMethod("Demo.java");
}
public static void fileMethod(String filename)
{
String[] arr = filename.split(".");
System.out.println(arr[arr.length -1]);
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at Demo4.fileMethod(Demo4.java:10)
at Demo4.main(Demo4.java:5) |