title: Alternating patterns in java
body: <p>Hello in trying to figure out how to make the following pattern in java</p>
  
  <pre><code> xoxox
   oxoxo
   xoxox
  </code></pre>
  
  <p>Im recently learning and have been trying to figure it out for hours.  Here is the code that i have so far. It mainly has to do with the last part under
    public static String textBoxString(int rows, int cols, char c1, char c2) </p>
  
  <pre><code>public class TextBoxTester {
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
          String s = TextBox.textBoxString(3);
          System.out.println(s);
  
          s = TextBox.textBoxString(4, '+');
          System.out.println(s);
  
          s = TextBox.textBoxString(3, 4);
          System.out.println(s);
  
          s = TextBox.textBoxString(3, 5, 'x', 'o');
          System.out.println(s);
  
      }
  }
  
  public class TextBox {
  
      public static String textBoxString(int side) {
          String s = "";
          for (int i = 0; i &lt; side; i++) {
              for (int j = 0; j &lt; side; j++)
                  s += "*";
              s += "\n";
          }
          return s;
      }
  
      public static String textBoxString(int side, char bChar) {
          String s = "";
          for (int i = 0; i &lt; side; i++) {
              for (char j = 39; j &lt; bChar; j++)
                  s += bChar;
              s += "\n";
          }
          return s;
      }
  
      public static String textBoxString(int rows, int cols) {
          String s = "";
          for (int i = 0; i &lt; rows; i++) {
              for (int j = 0; j &lt; cols; j++)
                  s += "*";
              s += "\n";
          }
          return s;
      }
  
      public static String textBoxString(int rows, int cols, char c1, char c2) {
          char c = c1;
          char d = c2;
          String s = "";
          for (int i = 0; i &lt; rows; i++) {
              for (int j = 0; j &lt; cols; j++)
                  s += c;
                      if (c == c1) {
                          c2++;
                      } else {
                          c1 = c;
                      }
                      s += "\n";
          }
          return s;
      }
  }
  </code></pre>