Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Flow Control -JQ+

 
Arun Pai
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jamal,
Really fast and the solution is quite simple.Thanks a lot.
-Arun
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Arun Pai
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jose,
Thanks and what is this???
Well, I have been good looking for a long time before Map noticing it.
 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic