I want to create a method that will use a phrase and a number taken from args. The number form args will shift the letters of the phrase from args the amount of letters the number is.
example javac Caesar.java java Caesar abcd 1
the end result should print bcde
my method is giving me problems.. help?
private String encode(String num, int x)
{
char[] charnum = args[1];
for (x = 0; x <= charnum.length; x++)
{
charnum = charnum + x;
}
return new String(charnum);
}
What do I do? Similarly i have to write a decoder method. I was going to have the same set up except the effects of the for loop change to
charnum = charnum - x;
My problem is that when I try to compile, I get the following errors
symbol : variable argslocation: class Lab041
char[] charnum = args[1];
^
Lab041.java:17: operator + cannot be applied to char[],int
charnum = charnum + x;
^
2 errors
how do i fix it? and is my assumption for the decode method correct?