java arrays

Hello have what is probably a small problem, I have a java array class with this code in it:-

  int NUMBER_OF_YEARS = 5;
    String yearsWorked[] = {"First Year", "Five Years", "10 Years", "Fifteen Years", "Twenty Years"};
    double[] total_Wages = new double[NUMBER_OF_YEARS];
     * arrays class fills the array with the users input
    public void Arrays() throws IOException
        double sum = 0;
        for (int i = 1; (i <=NUMBER_OF_YEARS); i++)
            System.out.println("Enter amount you expect to earn after "+yearsWorked[i-1]);
            //create an instance of the readline class
            UserInput wages_Earned = new UserInput();
            double wage =  wages_Earned.readDouble();
            sum+= wage;
            total_Wages[i-1] = wage;

what I want to do is refrence a specific location from another class I have tried using:-
arrayInput = arrayInput.total_Wages[4];
but this does not work any ideas much apreciated thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

what's the error?

I take it arrayInput is an instance of the Class which contains the above method?
you could make total_Wages data member public:

ie: public double[] total_Wages = ...

but the best practice is to create a getter:

public double[] getTotalWages() { return total_Wages; }

then you can do (assuming arrayInput is your class):

double[] totWages = arrayInput.getTotalWages();
myVal = totWages[4];

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BennettAuthor Commented:
yes arrayInput is an instance of the class containing the method.
the error I get is
found double required Arrays
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

> arrayInput = arrayInput.total_Wages[4];

this line doesn't make any sense.

if arrayInput is the instance of your class, your are trying to assign total_Wages[4] (a double) to your instance which is of type Arrays.
BennettAuthor Commented:
sorry yeah youre right the line is
wages = arrayinput.totalWages[4]
so is it working now?

if not, what is wages? it should be a double.
if so, please accept a comment as answer so this can be moved to PAQ (previously asked questions)
BennettAuthor Commented:
sorry yeah youre right the line is
wages = arrayinput.totalWages[4]
BennettAuthor Commented:
Ok its not a race, thanks for the help, you can have the points now. ;-)
BennettAuthor Commented:
Thanks very much for the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.