Understanding tables in Dynamic programming
dp[i][j] represents whether text[i..] matches pattern[j..].

If pattern[j..] is starting with x* for some symbol x (including .), then text[i..] matches pattern[j..], or x*pattern[(j+2)..], if and only if 


text[i..] matches pattern[(j+2)..] (i.e. x* matches an empty string), or
text[i] is x and text[(i+1)..] matches x*pattern[(j+2)..] (i.e. x* matches a non-empty string).


This is implemented by this part of code:

if (j + 1 &lt; pattern.length() &amp;&amp; pattern.charAt(j+1) == '*'){
    dp[i][j] = dp[i][j+2] || first_match &amp;&amp; dp[i+1][j];
}


On the other hand, if pattern[j..] is not starting with x*, text[i..] matches pattern[j..] if and only if text[i] matches pattern[j] and text[(i+1)..] matches pattern[(j+1)..]. This is implemented by this part of code:

else {
    dp[i][j] = first_match &amp;&amp; dp[i+1][j+1];
}