This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Returning an Array from a Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Returning an Array from a Method" Watch "Returning an Array from a Method" New topic
Author

Returning an Array from a Method

Tony Costello
Greenhorn

Joined: May 10, 2009
Posts: 2
Hello all I am attempting to write a method which gathers values from a text file, sticks em in an array and return the array.

I keep getting an error upon compiling:

java:41: '.class' expected
return age[];


Here is my code:

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18765
    
  40

The parameter "age", is an int array, and you need to return an int array... so...



is what you want.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Tony Costello
Greenhorn

Joined: May 10, 2009
Posts: 2
Oh geez.....thanks!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Returning an Array from a Method