String d_result = "";
str = str.toUpperCase();//String value is converted into upper case
//here loop converts takes encrypted text and converts it into original text using key value.
for(int i = 0, j = 0; i < str.length(); i++)
//The below defined for loop process each and every character in the encrypted text
//until the entire string is converted to its original form.
//These lines takes each character of the encrypted text at a time and check if it lies between the ascii
//range of character 'A' and 'Z'. Characters are only processed if the character lies in the range,
//else we move on to process next character of the encrypted text.
char c = str.charAt(i);
if(c < 'A' || c >'Z')
//The encrypted character is converted to the original character using the formula that uses the key value.
// The next character of the key value is obtained by using modulus operator that repeats the characters of
//the key so that its total length is equal to that of the original text.
result += (char)((c - k.charAt(j)+ 26)% 26 + 'A');
j = ++j % k.length();
//returns the plain text.