Question: Where would you post the comments for this java code import java.util.InputMismatchException; import java.util.Scanner; public class ArrayValue { static Scanner in = new Scanner(System.in); public

Where would you post the comments for this java code

import java.util.InputMismatchException; import java.util.Scanner;

public class ArrayValue { static Scanner in = new Scanner(System.in);

public static int getInt() { System.out.print("Enter an index position: "); try { return Integer.parseInt(in.nextLine()); } catch(Exception e) { throw new InputMismatchException(); } } public static void fillArray(int arr[]) { for(int i=0; i= arr.length) { System.out.println("Array out of bounds"); } else { System.out.println("Value at index " + index + " is " + arr[index]); } } public static void main(String[] args) { int arr[] = new int[100]; fillArray(arr); int index = -1; while(true) { try { index = getInt(); showValue(arr, index); break; } catch (Exception e) { System.out.println("invalid input, try again."); } } }

}

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!