Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I fix this error? The Coding Language is Java . public class AppleOrange { public static void main(String[] args) { int x =

How do I fix this error? The Coding Language is Java.

public class AppleOrange {

public static void main(String[] args) {

int x = Integer.valueOf(args[0]);

for (int i = 0; i <= x ; i++) {

if (i%3==0) {

System.out.print("apple");

}

else if (i%7==0) {

System.out.print("orange");

}

else if (i%3 == 0 || i%7 == 0) {

System.out.print("appleorange");

}

else {

System.out.print(i + " ");

}

}

}

}

Error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at AppleOrange.main(AppleOrange.java:5)

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

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

Explain strong and weak atoms with examples.

Answered: 1 week ago

Question

Explain the alkaline nature of aqueous solution of making soda.

Answered: 1 week ago

Question

Comment on the pH value of lattice solutions of salts.

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago