0

I have recently begun Java and was writing a program to encrypt normal English to a code based on some rules. The problem with the code is that I am setting a String variable to return, but it's not returning anything and coming as blank. Here's the code:

char c;
int r;
int l=mt.length(); \\mt variable is the entered string
String resu=""; \\resu variable is the string to return
for(int x=0;x<l;x++)
{
  c=mt.charAt(x);
    if((int)c<=90 && (int)c>=65)
    {
      r=100-(int)c;
      resu.concat("i"+Integer.toString(r));
    }
    else if((int)c<=122 && (int)c>=97)
    {
      c-=32;
      r=100-(int)c;
      resu.concat(Integer.toString(r));
    }
  }
System.out.println(resu);
return resu;

I was expecting the String 'resu' to contain the encrypted code but even when printing it, it turns blank.

devpolo
  • 2,487
  • 3
  • 12
  • 28

0 Answers0