aspose file tools*
The moose likes Beginning Java and the fly likes returning values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "returning values" Watch "returning values" New topic
Author

returning values

Graham Robinson
Greenhorn

Joined: Nov 23, 2005
Posts: 16
I have it so it will return 1 value, but if i need to take it more than one value in my class how would i do it?

The example here should take the grades of 4 students, to find the average but i don't know how to take it more than one, here's some code.



this is link to a file called marks, where the grades of four students are entered using an array.

Cheers.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
I'm not clear about your question.

If you are asking if you can return more than one value from a method, you can't.

If you want multiple values from a method, you should encapsulate them in a class definition and return an instance of that class.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Your English is difficult to understand (perhaps you could get someone who speaks better English to write your post) but I think you are asking how to find the average grade of a group of students. An instance of StudentV2 represents *one* student, so I don't think it makes sense for such an object to know the average of four students. You could define a class, say StudentCohort, that holds a collection of students. If you ask a cohort for its average, it will find that out by asking each individual for its grade, then doing the math.


There is no emoticon for what I am feeling!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: returning values