18 Replies
ā
This post has been reserved for your question.
Hey @Mike B! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Im trying to understand how to loop through this and why coffee is printing 10 times
It looks like you are having issues with debugging or issues that can be solved using a debugger.
Check out this article on dev.java to see how debugging works and how to use a debugger.
This Stack Overflow question and its answers also explain debugging in general.
These links describe how to use the debugger in some IDEs:
ā¢ Debugging in IntelliJ
ā¢ Debugging in Eclipse
the part confusing me is that, yes it prints the first time but then j increases to 1 and then i is now greater than i so then i increases to 1 and then j goes to 2 and then i goes to 2 and so on
you can step through it with a debugger and it will show you
so?
why does coffee print 10 times or atleast how does it
In the first iteration, i is 0 so the inner loop is executed 0 timrs
in the second iteration,
i
is 1, the inner loop/println os ececuted onceohh okay so it doesn't print the first time
ohh okayyy
totally makes sense
thanks
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
0<0 is false
i
is 0 and j
is 0 so j<i
is 0<0
which is falseohh okay
and then if im correct
but if you use a debugger, you can run it and it will show what exactly happens
once it prints does j increase again or does it go back to the our loop and
ok let me check that
j increases with every itetation of the inner loop - and it resets every iteration of the outer loop
ohh okay that makes sense
wow
so basically every time j > i it resets and the out loop then increases
j is only valid in the inner loop
after the inner loop ends, j is destroyed
and it is created when the inner loop starts
it all makes sense now thanks!!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
š¤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
š¤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.