Print LCS - One test case failing

On submitting one test case is showing run error.

import java.util.*;
public class Main {
public static void main(String args[]) {

	Scanner sc=new Scanner(System.in);

	String a=sc.next();
	String b=sc.next();

	subsequence (a,b);
}

static void subsequence (String a, String b) {

	String[][] dp=new String [a.length()+1][b.length()+1];

	for (int i=0; i<=a.length(); i++) {
		dp[i][a.length()]="";
	}
	for (int i=0; i<=b.length(); i++) {
		dp[b.length()][i]="";
	}

	for (int i=a.length()-1; i>=0; i--) {

		for (int j=b.length()-1; j>=0; j--) {

			if (a.charAt(i)==b.charAt(j)) {
				dp[i][j]=a.charAt(i) + dp[i+1][j+1];
			} else {
				if (dp[i+1][j].length()>=dp[i][j+1].length()) {
					dp[i][j]=dp[i+1][j];
				} else {
					dp[i][j]=dp[i][j+1];
				}
			}
		}
	}

	System.out.println (dp[0][0]);
}

}