I want to have a char, add number to it and get another char(a+2=c)
int leng,leng2;
String word = "";
String key = "";
String enc ="";
char x;
char z;
char tost;
System.out.println("gimme word");
word=in.next();
System.out.println("gimme key");
key=in.next();
leng=word.length();
leng2=key.length();
for(int i=1;i<=leng;i++)
{
z=word.charAt(i-1);
x=key.charAt(i-1);
int plus=z + x;
tost=(char)plus;
enc=enc+tost;
System.out.println(enc);
System.out.println(tost);
System.out.println((char)z);
System.out.println((char)x);
System.out.println(plus);
System.out.println((char)plus);
}
I want it to print c
and in my code I do it with charAt
because I have a full string and I tried to search for many solutions, and tried myself many things, they all didnt work sadly.
edit: full code is on, as requested the way of char plus doesnt work and says it is an error