• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Cannot figure out what declaration to put in

 
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
author & internet detective
Posts: 41250
849
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://ideone.com/9MX8Z

I keep getting an error regardless of how I change things.

 
Jeanne Boyarsky
author & internet detective
Posts: 41250
849
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
Posts: 24
Eclipse IDE Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
arrays. I should have known. Thanks!
 
Jeanne Boyarsky
author & internet detective
Posts: 41250
849
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic