- #1
- 265
- 0
Homework Statement
So I'm trying to create a method in java. The method is supposed to take a string and use the rot13 method to hide the message. That is, it takes each letter and places it forward 13 letters, so a becomes n, b becomes o, etc.
Now I'm pretty sure this method is at least on the right track, but what has been driving me crazy is I keep getting a compile error:
program.java:16: ';' expected
String newMessage += message.charAt(i) + 13;
^
1 error
How the heck am I supposed to put a damn semi colon in the middle of a string name? I hate it when I get an error that just ain't so!
Homework Equations
here is my code:
import java.util.*;
public class MessageEncryption
{
public static void main(String[] args)
{
//code goes here
}
public static String hideMessage(String message)
{
for (int i = 0; i <= message.length() - 1; i++)
{
//String letter = message.charAt(i) + 13; < maybe this is redundant.
String newMessage += message.charAt(i) + 13;
return newMessage;
}
return;
}
}
The Attempt at a Solution
Just been fiddling with the code. Thank you in advance!