title: (Beginner Java) Python time.sleep() equivalent in Java? Google says Thread.sleep() for multi-threaded stuff, but trying that throws an error
body: <p>I'm working on an example in Daniel Liang's <em>Introduction to Java</em>, and I'm trying to step through the problem to see what exactly is happening, but everything prints out too quickly. So, I'm looking for an equivalent in Java to Python's time.sleep().</p>
  
  <p>I know I could make a timer via <code>currentTimeMillis</code>, but a simple sleep function would be much more handy. </p>
  
  <p>I've tried typing <code>Thread.sleep(millis)</code> as suggested on google -- as well as <code>Thread.getCurrentThread.sleep()</code>, but both are giving the following error: </p>
  
  <blockquote>
    <p>error: unreported exception InterruptedException; must be caught or
    declared to be thrown
                  Thread.sleep(1000);</p>
  </blockquote>
  
  <p>This is the piece of code in question: </p>
  
  <pre><code>        for (int j = i; j&lt;100; j+=i){
  
              Thread.sleep(1000);
              System.out.println(j);
  
          }
  </code></pre>