This is part of a bigger project but i am having a problem with something fairly basic. I keep getting an array out of bounds exception. Can you advise why?
public class Arrayif {
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, ParseException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, InterruptedException {
String[] strarray = new String[0];
String liveBoA = "test";
if (strarray[0].isEmpty()) {
strarray[0] = liveBoA;
System.out.println("hello");
} else if (strarray[0].contains(liveBoA)) {
System.out.println("bellow");
}
}
}
This doesnt work either:
public class Arrayif {
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, ParseException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, InterruptedException {
String[] strarray = new String[1];
String liveBoA = "test";
if (strarray[0].isEmpty()) {
strarray[0] = liveBoA;
System.out.println("hello");
} else if (strarray[0].contains(liveBoA)) {
System.out.println("bellow");
}
}
}