title: How to shift characters in an array left in Java?
body: <p>This is what I have right now:</p>
  
  <pre><code>class encoded{
      public static void main(String[] args){
          int shift = In.getInt();
          String s1 = "bool";
          char[] ch=s1.toCharArray();
          for(int i=0;i&lt;ch.length;i++){  
              char c = (char) (((ch[i] - 'a' - shift) % 26) + 'a');
              System.out.print(c);
          }
      }
  }
  </code></pre>
  
  <p>This code works to shift all characters in the string left by however much I want it to shift. The problem arises when, for example, I shift 'abc' 1 left, it returns '`ab'. What I want is for the characters to wrap back around to 'z' instead, so that the shifted 'abc' becomes 'zab' instead. How would I go about doing this? The characters need to always wrap back around to z when they're shifted left of 'a', and need to wrap back around to a when they're shifted right of 'z' (this would be done by changing "'a' - shift" to "'a' + shift".
  Thanks so much in advance!</p>