Improvement in Manmohan Loves Pattern - I

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();

	int val1 = 1;
	int val0 = 0;

	for(int row = 1;row<=n;row++){
		if(row%2 != 0){
			for(int i = 1;i<row;i++){
				System.out.print(val1);
			}
			System.out.println(val1);
		}
		else{
			System.out.print(val1);
			int zero = row-2;
			for(;zero>0;zero--){
				System.out.print(val0);
			}
			System.out.println(val1);
		}
	}
}

}

This code is working, but is there a way i can optimize this?

I don’t think you can give.it any major optimization since this is really basic piece of code

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.