aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Please help me out this problem.look at last line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Please help me out this problem.look at last line" Watch "Please help me out this problem.look at last line" New topic
Author

Please help me out this problem.look at last line

Karu Raj
Ranch Hand

Joined: Aug 31, 2005
Posts: 479

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 ???
please help me


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

Joined: Mar 18, 2005
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 :-)


Only those who will risk going too far can possibly find out how far one can go !!!
Karu Raj
Ranch Hand

Joined: Aug 31, 2005
Posts: 479
thanks a lot

god bless you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help me out this problem.look at last line