Re: Need help with loop



meena.desani wrote:
why isn't the second part of my triangle not working?
import java.util.*;

public class triangle
{

public static void main(String[] args)
{
int nLines = 5;
for (int row = 1; row <= nLines; row++)
{
for (int star= 1; star <= row; star++)
System.out.print("*");
System.out.println();
}

}

}


If you really mean "Why isn't it not working?" the answer is because the
loops are correct, assuming you wanted a triangle of asterisks, though
very untidy.

Patricia


.