I think sir thios code of my mine is wrong because i have printed the output in anticlockwise . while array is not changed

import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scn =new Scanner(System.in);
int rows=scn.nextInt();
int[][] array=new int[rows][rows];
for(int i=0;i<array.length;i++) {
for(int j=0;j<array[i].length;j++) {
array[i][j]=scn.nextInt();
}
}spiralprint(array);

}

private static void spiralprint(int[][] arr) {
	int top = 0;
	int bottom = arr.length - 1;
	int right = arr[top].length - 1;
	int left = 0;
	int dir = 1;
	int count = (bottom + 1) * (right + 1);
	while (right >= 0) {
		if (count > 0) {
			if (dir == 1) {
				for (int i = top; i <= bottom; i++) {
					System.out.print(arr[i][right] + " ");
					count--;
				}
				System.out.println();
				right -= 1;
			}

		}

	}

}

}

@Harsh_Sonwani,
In the submissions, it shows that you have got a correct answer for the question. Do you have any further doubts regarding the question?

this run fine sir
whats ur opinion

@Harsh_Sonwani,
My opinion on what?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.