• Post Reply Bookmark Topic Watch Topic
  • New Topic

JAVA / J2EE Course  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can anyone explain how m4a[0].counter get incremented? Thank you..
 
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because of this line of code?
 
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please always tell us where such questions come from. Is that from Head First Java?

When you have that sort of puzzle, you should get a pencil and paper. You write something like this
m4a = array[val0, val1, val2, val3, val4, …]
x = 0
start loop
etc etc
In that case it might be better to write what each of the Mix4 references in the array points to.

When you finish that, it may take a long time, but you will be able to envisage the program flow much better.
 
kavi lathigra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I understand.

m4a[0].counter , m4a[1].counter , m4a[2].counter , m4a[3].counter......

have their own counter instance variable.. is it right???
 
Campbell Ritchie
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which page in Head First? Then I can look in my copy.
 
kavi lathigra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure.. it is in Page number 90
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kavi lathigra wrote:if I understand.

m4a[0].counter , m4a[1].counter , m4a[2].counter , m4a[3].counter......

have their own counter instance variable.. is it right???

Yes, you have an array of Mix4 objects, each of those objects has its own copy of the counter instance variable.
 
kavi lathigra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you .!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!