How to Accumulate results
Hello I am very new to java and am writing a method that shifts each letter in a String over in the alphabet n times. I am having trouble figuring out a way to accumulate the results
Code Java:
Code:
public String shift(int n){
char character;
for (int i = 0; i < text.length(); i++)
{
character = text.charAt(i);
if(character>='A'&& character<='Z'){
character = (char) (character + n);
if (character>'Z')
character-=26;
// How to accumulate?
text=Character.toString(character);
}
}
return text;
}
any advice is appreciated! I have been suggested a String builder, but im not quite sure on how to use it, is there a simpler method?
Re: How to Accumulate results
Re: How to Accumulate results
Cross posted after being advised to use a StringBuilder at
Accumulation Help - Java Forums
Didn't even have the courtesy to thank the member who made the suggestion.
db