+ 1

What is the error of the following

public class Program { public static void main(String[] args) { int i,j,k,n; for(i=-3;n=Math .abs(i);n<=3;i++){ for (k=n;k>0;k--){ System .out .print(" ") ; } for (j=n;j<=2;j++){ System .out.print ("* ") ; } System .out .println (); n=Math .abs(i); } } }

24th Mar 2017, 4:29 PM
Anirban Mukherjee
Anirban Mukherjee - avatar
4 Answers
+ 5
first remove math.abs as integers accept negative as well as positive values, and if 1 and 2 are the 2 digits you want to print then why are you putting "* "
29th Mar 2017, 1:14 PM
Jibin Philipose
Jibin Philipose - avatar
+ 4
There are 4 arguments in your first for loop. There can only be 3. It also looks, on my screen, like you have unneeded spaces before your dots in your dot notation. Also, your print statements don't print anything.
24th Mar 2017, 5:01 PM
Louis
+ 1
But still the output is not coming
25th Mar 2017, 4:18 PM
Anirban Mukherjee
Anirban Mukherjee - avatar
+ 1
I want to print this- 1 1 2 1 1 2 3 2 1 1 2 1 1
25th Mar 2017, 4:20 PM
Anirban Mukherjee
Anirban Mukherjee - avatar