wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Array question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array question" Watch "Array question" New topic

Array question

Brusse James

Joined: Nov 22, 2002
Posts: 7
Let's say I want to input (10) values into an array, and have them averaged, ok. Should I read each number in separately and them set those numbers to an array address? And is there an '.average' method? How can I make this quick and easy to follow (mostly for myself). Thanks in advance.
James Chegwidden
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
Use a for loop to read in numbers, use a var like sum to sum the values as you read them in and then finally divide by the number of elements.
There is no .average method. There is .length- it is not a method.

Author and Instructor, my book
Brusse James

Joined: Nov 22, 2002
Posts: 7
Thanks for the help. I'll give it a shot and get back to you with any further questions.
Brusse James
jQuery in Action, 2nd edition
subject: Array question
Similar Threads
question on array and printing
Putting data into JTextField
How do you add to Arrays together?
Holding threads in an array
JComboBox Array