This might be a stupid question but I can't figure out how to set my array equal to my method which returns an array.

This is what I did and there's an error. :/

array=array.resize();

Thanks guys

Recommended Answers

What is the error??

Jump to Post

It is already there. Check first line ;)

Jump to Post

All 5 Replies

What is the error??

Example

int[] numbers = getNumbers();


private int[] getNumbers(){
    int[] numbers = new int[10];
    //some code to populate array

    return numbers;
}

You then can use peter_budo's method like this:

int[] varArr = getNumbers();

It is already there. Check first line ;)

Good news: still know my Java.
Bad news: need to get my eyes checked.

:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.