Try/Catch – Safe Array Access Write a Java method that takes…
Try/Catch – Safe Array Access Write a Java method that takes an integer array and an index,prints the value at that index,and uses a try/catch block to handle invalid index access by printing”Index out of bounds” instead of crashing. Example call:safeAccess(new int{5, 10, 15}, 0); → prints “Value is 5”