Re: Need help with loop



Lion-O wrote:
why isn't the second part of my triangle not working?


for (int row = 1; row <= nLines; row++)
{
for (int star= 1; star <= row; star++)
System.out.print("*");
System.out.println();
}


Note the missing { ?

Actually, the braces matched. The for loop has only one line, the System.out.print().

Note that in the original post there were three opening braces and three closing braces. Adding one opening brace would cause compilation failure.

- Lew
.



Relevant Pages

  • Re: try catch question
    ... am in the middle of debugging someone else's code and am getting more ... I think the squiggly braces aren't always paired as they should be. ... catch exception ex { ... Note that the opening braces are not parrallel with the closing ones. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Brace problem
    ... > peek and advise: ... Put spaces before and after your braces. ... Or rather before opening braces ... and after closing braces. ...
    (comp.lang.tcl)
  • Re: While loop style
    ... Using the braces would have made it clear what the intention was and more ... > Why have while loops with blocks and another while loop withouts blocks ... the queue do not provide a isEmpty funtion. ...
    (microsoft.public.vc.language)
  • Re: for problem...
    ... DC>> David Cobac, ... DC>>to use floating point numbers as part of a loop control structure, ... Removing the braces should not make any difference. ...
    (comp.lang.tcl)
  • Re: [PATCH] bracing the loop in kernel/softirq.c
    ... Do not unnecessarily use braces where a single statement will do. ... it fails on further loop modifications. ...
    (Linux-Kernel)