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) {](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f30e28d3978_90466f30e2882d55.jpg)
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
Get step-by-step solutions from verified subject matter experts
