Counting exponent with long variables and Arrays, still error .. help anyone?

Hello!

i'm new to this forum, hope this comes to the right place ..

I'm still learning Java, trying to program a method what will calculate exponent from a basenumber.

it seems to work, but still gives error message.

here is the code:

---------------------------

import java.util.Scanner;

public class Count_exponent

{

public static void main(String[] args)

{

int i, a, b, baseNumber, toExpo;

int number1, number2;

Scanner input = new Scanner( System.in );

System.out.println("Give the base Number: ");

number1= input.nextInt(); // read first number from user

System.out.println("Give the toExponent number: ");

number2= input.nextInt(); // read second number from user

baseNumber = number1;

toExpo = number2;

long[] longArray = new long[toExpo];

a=0;

b=1;

for (i=0; i<toExpo; i++)

{

longArray[i]=(long)baseNumber;

System.out.println(longArray[i]);

}

for (i=0; i<toExpo; i++)

{

longArray[a]=longArray[a]*longArray[b];

System.out.println (longArray[0]); // this line prints on screen the exponent counted

b=b+1; // at every step

}

System.out.println ( "Answer is: ");

System.out.println (longArray[0]); // program seems to count exponents ok, but gives

} // error before printing the final answer.

}

// Can anyone help me with

// this program, what is it doing

// wrong?

----------------------