Question: Please update Java code, I keep getting Index 0 out of bounds for length 0. Here is the code: public class Demo2 { String[] egg

Please update Java code, I keep getting Index 0 out of bounds for length 0. Here is the code:

public class Demo2 {

String[] egg = {"*****", "* *", "* *", "* *","*****"};

String[] uno = {" **"," *"," *"," *"," *"};

String[] dos = {"*****", " *", "*****", "* ","*****"};

String[] tres = {"*****", " *", "*****", " *","*****"};

String quad = {"* *", "* *", "*****", " *"," *"};

public void displayDemo(int a, int b) {

String [] nums = {egg, uno, dos, tres, quad};

for(int i = 0; i

System.out.println(nums[a][i]+" "+" "+nums[b][i]);

//Should return whatever equivalent ints are.

}

}

public void InputDemo(String ab) {

int a=Integer.parseInt(a.substring(0,1));

int b=Integer.parseInt(b.substring(1,2));

displayDemo(a, b);

}

public static void main(String[] args) {

Demo2 demo = new Demo2();

demo.InputDemo("12");

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!