There are 2 problems in your code which you'll need to fix first:
- your array index is bigger than the size of the array (11 > 9)
- the number you're assigning to 'a' is too big for the integer type
You could try this as a solution:
StringBuilder numbers = new StringBuilder();
int[] num = new int[9];
for (int i = 0; i < num.length; i++) {
num[i] = i;
numbers.append(i);
}
long a = Long.valueOf(numbers.toString());
System.out.println(a);
Note that you'll still need to check that the final output of 'numbers' is not too big for a long. If it is you'll need to use a data type that can accommodate the resulting value.