I am trying to print a pattern through java. I am using for loop and a conditional statement but there is some problem with && operator. I am not getting why it is behaving strange with my code specially. Following is my code.
public class Test{
public static void main(String ar[]){
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if((i!=0 && j!=0)){
System.out.print("*");
}else{
System.out.print(" ");
}
}
System.out.println();
}
}
}
output
unknown@unknown-Lenovo-E40-80:~/Desktop/java_test$ javac Test.java
unknown@unknown-Lenovo-E40-80:~/Desktop/java_test$ java Test
****
****
****
****
above output is totally different to my expectation. line 1 is not printed why? i just wanted to skip (i=0 and j=0) location's element.