• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need some elaborations on this code

 
Arnel Colar
Greenhorn
Posts: 7
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anyone explain to me this code. I got this problem while reading "HeadFirst Java 2nd Edition". I'm still dumb when it comes to arrays and loops.

Here is the code:


And this is the output:
14 1

It will also be a great help if someone suggest websites or techniques on how I can easily understand loops and arrays especially when arrays are under a loop or they appear similar to the problem that I posted here. These are my weakness. I want to be able to surpass this so that I can progress more in Java programming.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go through the program line by line in your head, remembering what the values of variables are; in other words, try to run the program in your head. Tell us what you think happens, step by step. If there is a specific step you don't get, then explain us what step that is exactly and we'll help you clear the confusion.
 
Arnel Colar
Greenhorn
Posts: 7
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I'll read again that part of the book then simulate this code. Isn't it that:

is the counter and it will be put to then it increments until x<9 is met.

Am I correct?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic