I am getting this error when I enter Long 123456

```
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 4
at java.lang.String.charAt(Unknown Source)
at thuchanh01.Baitap05.sumDigits(Baitap05.java:17)
at thuchanh01.Baitap05.main(Baitap05.java:31)

```

My code:
(Please note that the code is still complete and I have entered some print statements for checking)

```
package thuchanh01;

import java.util.Scanner;

public class Baitap05 {
private static Scanner input;
public static int sumDigits(long n)
{
    String arrayN = Long.toString(n); //conver long to string
    int len = arrayN.length(); //length of string
    Character[] array = new Character[len]; //create char array with length = length string
    int sum = 0;

    for(int i = 0; i<=len; i++)
    {
        array[i] = new Character(arrayN.charAt(i)); //assign array[i] = arrayN[i]
        sum = sum + array[i]; //result sum
    }
    return sum;

}

public static void main (String[] args)
    {
        long dayso;
        long sum = 0;
        input = new Scanner(System.in);
        System.out.println("Nhap vao day so = ");
        dayso = input.nextLong();
        sum = sumDigits(dayso);
        System.out.println("Tong can tim = " + sum);

    }

```

}