Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. Give some examples of hidden knowledge.

Answered: 1 week ago