How do I access a variables created in a function with another function?

I have created a multiple arrays in a function that I would like to accress from another function. For instance I have created a function called getStuff and in it I create several arrays and will them with objects or strings or some numeric varibles. Point is a few different types of arrays. Once the function is complete I want to keep the arrays around until I press a button then I want the arrays to be destroyed and new arrays made with new variables to fill them. Any ideas or question?

If you do this:

void myFunct() {
  int myVar = 5;

You CAN NOT ACCESS that myVar ANYWHERE outside that function. You could however do this:

In your class, declare needed variables:

int myVar;
float[] myArray;

In your function you use those variables to save the data you need.

void DoSomething() {
  myVar = 5;
  myArray = new float[]{1f, .5f, .1f};

Then when you press a button you just call the DoSomething function. It will create new values by itself and store them in those variables.