aspose file tools*
The moose likes Beginning Java and the fly likes Cannot figure out what declaration to put in Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot figure out what declaration to put in" Watch "Cannot figure out what declaration to put in" New topic
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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30780
    
157

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: 18896
    
  40

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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30780
    
157

"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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30780
    
157

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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot figure out what declaration to put in