*
The moose likes Beginning Java and the fly likes I need some elaborations on this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I need some elaborations on this code" Watch "I need some elaborations on this code" New topic
Author

I need some elaborations on this code

Arnel Colar
Greenhorn

Joined: Apr 14, 2011
Posts: 7

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.

http://magicduel.com/register/register.php?refererID=217409
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Arnel Colar
Greenhorn

Joined: Apr 14, 2011
Posts: 7

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I need some elaborations on this code