title: Java: Next character in String
body: <p>I have one String generated of random characters that will encrypt another String given by the user by adding the first character from the String with the first character of the given String. It's working fine, but if the user were to enter multiple words with spaces in between, I want to choose the next character of the first String rather than code the space itself. Is that possible? This is what I have:</p>
  
  <p>(random is the coded string and sentenceUpper is string given by user)</p>
  
  <pre><code>public static void encrypt(String sentenceUpper){
  
  String newSentence = "";
  
  for(int i = 0; i &lt; sentenceUpper.length(); i++){
   char one = random.charAt(i);
   char two = sentenceUpper.charAt(i);
  
   if(one &lt; 'A' || one &gt; 'Z'){
    two = sentenceUpper.charAt(1 + i);}
  
   char result = (char)((one + two)%26 + 'A');
   newSentence += "" + result;
  </code></pre>
  
  <p>}</p>
  
  <p>EDIT FOR BETTER EXPLANATION:</p>
  
  <p>I have:</p>
  
  <p>String random = "WFAZYZAZOHS";</p>
  
  <p>I would like to code user input:</p>
  
  <p>String upperCase: "YOU GO";</p>
  
  <p>So, I'm going to take Y + L = U, etc...
  to get :
  "UTUSEN
  "
  But I see that there's a space in "YOU GO" , So I'd like to change it to:
   WFA ZY + YOU GO = UTU SE.</p>
  
  <p>I hope that's better explained.</p>