File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes variable of interest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "variable of interest" Watch "variable of interest" New topic
Author

variable of interest

Marcus Deviln
Ranch Hand

Joined: Jan 29, 2009
Posts: 39
I posted this code before but I must admit I still don't quite get it. What is the count variable counting when it prints out 4? I can see that there 4 array objects. Is that it?



+Deviln+ The power of JAVA compels you!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

There is no count variable, only an index. It's printing an element from the arrays.
Marcus Deviln
Ranch Hand

Joined: Jan 29, 2009
Posts: 39
so if it's printing an element from the array then it must be the '4' in the middle array correct? That's index [1][2] (index from zero), no?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's the only 4 I see, yeah.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Marcus Deviln wrote:so if it's printing an element from the array then it must be the '4' in the middle array correct? That's index [1][2] (index from zero), no?

Right. The reason is the initial value of index (1) and the post-increment in the indexing.

In short, what happens is this:
- the value of index is retrieved, 1
- index is increased to 2
- dd[1] is evaluated
- the value of index is retrieved, 2
- index is increased to 3
- dd[1][2] is evaluated

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: variable of interest
 
Similar Threads
Doubt related to post-increment operators
Multidimensional arrays
Order of precedence
Possible error in question from Kathy Sierray, Bert Bates SCJP6 book
Instance blocks.