File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Flow Control -JQ+ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Flow Control -JQ+" Watch "Flow Control -JQ+" New topic
Author

Flow Control -JQ+

Arun Pai
Ranch Hand

Joined: Mar 11, 2002
Posts: 143
This question has troubled me a lot, please help me to understand the logic.

I don't seem to understand how the output is 10. Please advise.
-Arun
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
Arun, I'll explain step by step:
i j k c (k>j)
0 0 0 1 false
0 0 1 2 true
0 1 0 3 false
0 1 1 4 false
0 1 2 5 true
1 0 0 6 false
1 0 1 7 true
1 1 0 8 false
1 1 1 9 false
1 1 2 10 true

Regards,
Jamal Hasanov
www.j-think.com
Arun Pai
Ranch Hand

Joined: Mar 11, 2002
Posts: 143
Hi Jamal,
Really fast and the solution is quite simple.Thanks a lot.
-Arun
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
These are the values when i is 0:
c=0
i=0
j=0
k=0
c=1
k=1
c=2
j=1
k=0
c=3
k=1
c=4
k=2
c=5
i=1
now i is 1 and the same it's repeated again,
but c is increamented up to 10


SCJP2. Please Indent your code using UBB Code
Arun Pai
Ranch Hand

Joined: Mar 11, 2002
Posts: 143
Jose,
Thanks and what is this???
Well, I have been good looking for a long time before Map noticing it.
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
By the way, Arun
try this method in exam: draw a table of variables(for example: variables are columns) and debug code step by step in paper.
This method helped me very much in exam.
Regards,
Jamal Hasanov
www.j-think.com
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Arun it's a joke about how good looking some bartenders are.
It was no addressed to anybody.
I think it is time to remove it
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Flow Control -JQ+
 
Similar Threads
Question from jqplus
confusing for Loop.
for loop
I am not getting the required output...
Evaluation order