• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

For Loop

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I get , in my for loop, where the value that is caught in the for loop in returned so I can use it in the method at the bottom of my syntax?

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your for loop isn't doing anything (and the initialization of "average" isn't legal) so I'm not sure what value you are talking about. If it's "average" then you are returning it already so you just call the getAverage() method and assign the returned value to a local variable or use it directly.

BTW Your toString() method is using "Grades" - the capital first letter implies it is a class name but you are using it as if it is an array in the first 4 lines so I guess it's a variable. The problem is you are then calling methods on Grades which aren't legal for an array, I suspect they are supposed to be called on one of the elements in the array.
I think it would help if you showed the whole class file and explained what your code is trying to achieve.
 
reply
    Bookmark Topic Watch Topic
  • New Topic