| Author |
Cannot figure out what declaration to put in
|
matthew meltzer
Greenhorn
Joined: Sep 08, 2012
Posts: 24
|
|
Q17: What declaration needs to be added into line (1) in order for this program
to print out 90 to the standard output?
I'm trying to figure out exactly what I have to put at line 1 to make the program print out 90 but I am getting nowhere and all my efforts lead to compilation errors.
Could anyone help point me in the right direction?
Thank you,
-Matthew Meltzer
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26218
|
|
What variable name is needed to make the code compile?
What type must it be? (There is actually more than one right answer to this one)
Start with these two and you'll get compiling code that doesn't print 90. Then try adding one value and seeing what gets printed. This will give you a clue as to the required values.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
matthew meltzer wrote:Q17: What declaration needs to be added into line (1) in order for this program
to print out 90 to the standard output?
I'm trying to figure out exactly what I have to put at line 1 to make the program print out 90 but I am getting nowhere and all my efforts lead to compilation errors.
Could anyone help point me in the right direction?
Hint: what types of objects can be looped through by the for-each loop?
[EDIT: note to self ... when returning to your computer, make sure to click reload before responding -- as the question may already been answered... ]
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
matthew meltzer
Greenhorn
Joined: Sep 08, 2012
Posts: 24
|
|
http://ideone.com/9MX8Z
I keep getting an error regardless of how I change things.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26218
|
|
|
"num" is correct on the line you added. int isn't the correct type. What types call you loop through using an enhanced for loop?
|
 |
matthew meltzer
Greenhorn
Joined: Sep 08, 2012
Posts: 24
|
|
|
arrays. I should have known. Thanks!
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26218
|
|
Yay! Thanks for bearing with us as you discovered the answer. You learn more that way. And we get to enjoy seeing you make the discovery!
|
 |
 |
|
|
subject: Cannot figure out what declaration to put in
|
|
|