0

How can I put some arrays into one larger holder array?

Here are my arrays:

int [] mySoundArray = {R.raw.piano_c1, R.raw.piano_d1};

int [] mySoundArrayTwo = {R.raw.piano_e1, R.raw.piano_f1};

I've tried this but it errors:

int [] totalSoundArray = {mySoundArray, mySoundArrayTwo};

1 Answer 1

3

Use this syntax:

int [][] totalSoundArray = {mySoundArray, mySoundArrayTwo};

Explanation: this is because what you are creating is an array of an array of ints.

int i // an int
int[] ii // an array of ints
int[][] iii // an array of an array of ints
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.