I have to convert this little piece of C# code to Java:
const int AM = 65521;
int GetCCSufix(string a)
{
int c = 1, b = 0, d, e;
var chars = a.ToCharArray();
for(e =0; e< chars.Length; e ++)
{
d = chars[e];
c = (c + d) % AM;
b = (b + c) % AM;
}
return b << 16 | c;
}
And I made it this:
private int getSuffix(String a) {
int constant = 65521;
int c = 1;
int b = 0;
int d = 0;
int e = 0;
for(e = 0; e < a.length(); e++){
d = a.charAt(e);
c = (c + d) % constant;
b = (b + c) % constant;
}
return b << 16 | c;
}
However, this doesn't seem to give me the same output as the C# code. What am i doing wrong?
returnstatement and check if the value ofbis same for both codes (for same string) ?a. Sorry for the inconvenience.