Arnel Colar

Greenhorn
+ Follow
since Apr 14, 2011
Arnel likes ...
Eclipse IDE Java Ubuntu
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Arnel Colar

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?
12 years ago
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.
12 years ago
Thanks Ralph. That explains some parts but why is it that when I remove d.snare = false i get this output:


and when I bring back d.snare = false I get this output:


I'm sorry if my questions are a bit confusing to some. I'm a Java beginner and also new in forums. I'll be more specific with my questions next time.
12 years ago
Hi,

My first post was the given solution in that book. This is my answer:
My first attempt:


My second attempt was correct but:


what confuses me is the solution in that book.
12 years ago
Hi,

I'm still confused how methods work. I am studying Java through Head First Java, a book that experienced Java developers suggests I begin my Java experience. I'm just in the Chapter 2 explaining methods when I came to this problem. Of course I tried my best to solve it but I got a wrong answer. So when I go to the solution page of the book, I got confused.

Here is what confuses me(I'll add comment on the part where I got confused):


The confusing part is the boolean thing and the methods inside DrumKit class. How was it able to work even though it is not inside in any of the 2 methods. Ex. I figured that topHat should be inside playTopHat() method to work and the same with snare and playSnare().
12 years ago
Thank you all for the welcome and thank you for explaining the code. I thought I would look like a complete idiot asking that question (I get that a lot on OTHER Java forums). It looks like this will be favorite Java forum starting today.
13 years ago
I was doing an exercise here in javaranch to say a number. I finished it and yet it felt a bit cluttered and there are too many redundant codes so I asked for help. Many helped but there was one that caught my attention. This code:


Every number I input works flawlessly. Then I got confused.. so here are my questions:
How did the say() method work?
Why is it that even if it is not on a loop the say() method works?
What is the role of boolean here?

13 years ago