Accessing variables from a for loop

I was thinking on is it possible to access variables inside the for loop to use them outside the loop.
For example access the int i outside the loop.

Yes, if you define the variable in the main scope, then you can use it anywhere in the main scope.
You can choose to use a for loop or a while loop.

For loop:
int i;
for (i = 0; i < somenumber; i++) {
// whatever you put in your loop

While loop:
int i = 0;
while (i < somenumber) {
// whatever you put in your loop

You can access int i anywhere inside whichever function you defined int i in:
Debug.Log ("int i = " + i);

Learn more about scope here.