0
can we convert nested loop in a single loo?
6 Antworten
+ 1
see example in below
public class Program
{
public static void main(String[] args) {
int i;
int j;
for(i=0,j=0;i<5;i++,j++){
System.out.println("i=" + i + " j=" + j);
}
}
}
+ 1
class A
{
static int i;
static
{
i = 100;
System.out.println(1);
}
static void staticMethod()
{
System.out.println(i);
System.out.println(2);
}
}
public class B
{
static
0
No. you cant becoz when outer for loop runs one time ,inner for loop may run n times ...
0
So if there is an example, why not copy and change to the point that you like to have?? this question is not good
- 1
but there is an example on yahoo in which nested loop is converted into a single loop.....
- 1
this is not converted from a nested loop Tiger..its a single loop.just used two variables