I have a sorted array of numbers with 10 elements, the user sets the index number and I need to output the number that is under this index.
public class ArrTest { public static class Array{ private int array[] = new int[10]; public void UnsortedArr(){ for (int i = 1; i < array.length; i++) { array[i] = (int) (Math.random() * 20); } for (int i : array) System.out.print(i + " "); } public void SortedArr(){ Arrays.sort(array); System.out.print("\n"); for (int i : array) System.out.print(i + " "); } public void ReturnValue(int retValue) { } } public static void main(String[] args) { Array arr = new Array(); arr.UnsortedArr(); arr.SortedArr(); System.out.println("\n Enter index: "); Scanner sc = new Scanner(System.in); int k = sc.nextInt(); arr.ReturnValue(k); }