Hi, im trying to use the following line of code but it says unexpected type - as far as i can see its a correct type:
in.charAt(i)=(char)(in.charAt(i)+key);
in is a string
key is an int
Whats wrong ?
My full code is :
import java.util.*;
import java.io.*;
public class Encryption
{
public void encrypt()throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println("Enter a string");
String in=br.readLine();
Random randnum = new Random();
int key = randnum.nextInt(91);
for (int i=0;i<in.length();i++)
{
in.charAt(i)=(char)(in.charAt(i)+key);
}
System.out.println("Encrypted string is: "+in+"/nKey: "+key);
}
}