first of all I'm a beginner in java language , i wanted to test myself in a problem which is to encrypt a message given by the user , the class was as shown , unfortunately when i tried to use the class in Main class it gave me an Exception "in thread "main" java.lang.NullPointerException",
public class engToEnc {
public String Message;
public char []c = new char [Message.length()];
public String readMessage(String pMessage)
{
this.Message = pMessage;
for(int i = 0 ; i < Message.length() ; i++)
{
c[i] = Message.charAt(i);
c[i] += (char)27;
}
Message = String.copyValueOf(c);
return Message;
}
}
i tried to simplify the function to see the reason for the exception like that
public String readMessage(String pMessage)
{
this.Message = pMessage;
return Message;
}
but it also gave me the same exception so i did know that i have an issue with passing the string parameter, please help !