Spiral anticlockwise

import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int m=sc.nextInt();
int n=sc.nextInt();
int i,j;
int count=0;
int count1=0;
int a[][]=new int[m][n];
int b[]=new int[100];
Arrays.fill(b,100);
int top=0;int left=0;int right=n-1;int bottom=m-1;
for(i=0;i<m;i++){
for( j=0;j<n;j++){
a[i][j]=sc.nextInt();
}
}
for(count1=1;count1<=m/2&&count1<=n/2;count1++){
for(i=top;i<=bottom;i++){
b[count++]=a[i][left];
}
for(i=top;i<=bottom;i++){
b[count++]=a[i][left];
}
for(i=left+1;i<=right;i++){
b[count++]=a[bottom][i];
}
for(i=bottom-1;i>=top;i–){
b[count++]=a[i][right];
}
for(i=right-1;i>left;i–){
b[count++]=a[top][i];
}
top++;
bottom–;
right–;
left++;
}
if(top==bottom && left==right){
b[count++]=a[top][left];
}
else if(top<bottom)
{
for(i=top;i<=bottom;i++){
b[count++]=a[i][left];
}
}
else if(left<right){
for(i=left;i<=right;i++)
{
b[count]=a[top][i];
}
}
for( i=0;i<m
n;i++){
System.out.print(b[i]+", ");
}
System.out.print(“END”);
}

}

plz help where i went wrong…i done max but last 3 digits are not getting as required

hey @karthik1989photos
4 4
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
11, 21, 31, 41, 11, 21, 31, 41, 42, 43, 44, 34, 24, 14, 13, 12, END
you are doing wrong
correct output : 11, 21, 31, 41, 42, 43, 44, 34, 24, 14, 13, 12, 22, 32, 33, 23, END

can u correct my code where i went wrong

@karthik1989photos
correct code