News

This is a simple Java program that swaps two elements in an array based on user input. The user specifies two indices, and the elements at those indices are swapped. This Java application performs the ...
// int[] arr1 = {1,2,3,4,5,6}; // works for any number of elements, even or odd int n = arr1.length/2; // to get floor half of the number of elements in the array ...