This week's book giveaway is in the Design forum.We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!

Karu Raj
Ranch Hand
Posts: 481

The answer is Element[1, 0]: 2
Element[2, 0]: 9
sum: 11

The question is why is [2,1] [1,2 ]is not calculated ???

( tags added, tabs by spaces and attempted to clean up formatting)
[ September 02, 2005: Message edited by: Barry Gaunt ]

Kalyana Sundaram
Ranch Hand
Posts: 94
Initially when I=0 and j=0 if(j==i) break; is executed and so control breaks out of the inner loop.
In the next iteration of the outter loop, we have
i=1 and j=0, this time the first if will not get exeuted and control proceeds to execute the System.out.println()

Output at this point is
Element[1, 0]: 2

And the value of sum is 2, which is less than 10, so second if is not executed

Now moving to next iteration of outter loop
i=2 and j=0, this time also the first if will not get exeuted and control proceeds to execute the System.out.println()

Output at this point is
Element[2, 0]: 9

Now sum is 9+2 =11 greater than 10, so the second if gets executed and comes out of the scope defined by the label outer:

Hope this helps :-)

Karu Raj
Ranch Hand
Posts: 481
thanks a lot

god bless you