Question: import java.util.Scanner; public class ArrayOut { public static void main(String[] args) { String[] testArray = {This, is, the, data, used, in, this, exercise}; Scanner sc

import java.util.Scanner;

public class ArrayOut { public static void main(String[] args) {

String[] testArray = {"This", "is", "the", "data", "used", "in", "this", "exercise"};

Scanner sc = new Scanner(System.in); System.out.print("Enter an index: "); int index = sc.nextInt(); sc.close();

//Write your code here that uses index and prints out the correct //thing. Remember the out of bounds condition. System.out.println(testArray[0]+""+testArray[1]+""+testArray[2]+""+testArray[3]+""+testArray[4]+""+testArray[5]+""+testArray[6]+""+testArray[7]); } }

import java.util.Scanner; public class ArrayOut { public static void main(String[] args) {

the red part is the incorrect output how do i get the correct output

which is Enter an index: Not in bounds.

- Enter an index: Thisisthedatausedinthisexercise + Enter an index: Not in bounds

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!