Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded
Houston, you have some bugs

The algorithm counts incorrectly in some cases involving zeros.
For example, there's only one way to make "10" or "20", not 2.

A different problem is the overly strict condition &lt;26,
which excludes "26" even it can be decoded to z.

Beware of string slicing

String.substring creates a new string.
This could become expensive when repeated often.
If you change the logic to work with a char[] instead of a String,
then you can check if the first digit is '1',
or the first digit is '2' and the second digit is &lt;= '6'.

Unnecessary code

This condition will never be true:


if((int)message.charAt(n-k)==0)



The characters in the input are in the range of '0'..'9',
therefore their int values are in the range of 48..57.

Unnecessary Integer[]

You could safely replace Integer[] with int[],
and use a condition on zero value instead of null value.