Manmoham loves pattern1 = help to improve this

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (j == 1 || j == i) {
System.out.print(“1”);
} else {
if (i % 2 == 0) {
if (j==1 || j==n){
System.out.print(“1”);
}else {
System.out.print(“0”);
}
}else{
System.out.print(“1”);
}
}
}
System.out.println();
}