title: pushback stream example in java textbook help. What is going on?
body: <p>I am reading this example in my java book:</p>
  
  <pre><code>// Demonstrate unread().
  
  import java.io.*;
  
  class PushbackInputStreamDemo {
      public static void main(String args[]) {
          String s = "if (a == 4) a = 0;\n";
          byte buf[] = s.getBytes();
          ByteArrayInputStream in = new ByteArrayInputStream(buf);
          int c;
  
          try ( PushbackInputStream f = new PushbackInputStream(in) )
          {
              while ((c = f.read()) != -1) {
                  switch(c) {
                  case '=':
                      if ((c = f.read()) == '=')
                          System.out.print(".eq.");
                      else {
                          System.out.print("&lt;-");
                          f.unread(c);
                      }
                      break;
                  default:
                      System.out.print((char) c);
                      break;
                  }
              }
          } catch(IOException e) {
              System.out.println("I/O Error: " + e);
          }
      }
  }
  </code></pre>
  
  <blockquote>
    <p>Here is the output for this example. Notice that == was replaced by ".eq." and = was replaced by "&lt;-".</p>
    
    <p>if (a .eq. 4) a &lt;- 0;</p>
  </blockquote>
  
  <p>When it reaches the single <code>=</code> sign, it reads it, prints out the <code>&lt;-</code> and then unreads the <code>=</code> and puts it back on the <code>pushbackInputStream</code> right? So when it calls <code>c = f.read()</code>, it receives the <code>=</code> again right? so why aren't we in an infinite loop of <code>&lt;-</code> symbols?</p>