Write a simple Java program of this question
The goal is to deal with fixed indices at which elements are present and to perform operations on indexes such that elements on the addressed should be swapped in such a manner it should lookout as the matrix is rotated. For a given matrix, the task is to rotate its elements in a clockwise direction. Here, order to print the elements in spiral form. Where, we will rotate all the rings of the elements one by one, starting from the outermost one. And for rotating a ring, we need to do the following: 1. Move the elements of the top row, 2. Move the elements of the last column, 3. Move the elements of the bottom row, and 4. Move the elements of the first column. Moreover, repeat the above steps if there is an inner ring as well. Details Example 1: 3x3 matrix Input: 7 8 9 10 11 12 2 3 4 Output: 10 7 8 2 11 9 3 4 12 Example 2: 4*4 matrix Input: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Output: 8 4 5 6 12 13 9 7 16 14 10 11 17 18 19 15