title: Finding prime numbers with a custom IsPrime method
body: <p>I started learning Java about one month ago and today I saw this question I couldn't solve.</p>
  
  <p>The question was: </p>
  
  <blockquote>
    <p>Write a method named <code>isPrime</code>, which takes an integer as an argument and returns <code>true</code>
    if the argument is a prime number, or <code>false</code> otherwise. Demonstrate the method in a complete program.</p>
  </blockquote>
  
  <p>And the second part says: </p>
  
  <blockquote>
    <p>Use the <code>isPrime</code> method that you wrote in previous program in a program that 
    stores a list of all the prime numbers from <code>1</code> through <code>100</code> in a file.</p>
  </blockquote>
  
  <p>Here's my code, which doesn't work:</p>
  
  <pre><code>import java.io.*;
  
  public class PrimeNumbers {
  
      public static void main (String args[]) throws IOException {
  
          PrintWriter outputFile = new PrintWriter("PrimeNumber.txt");
  
          int j = 0;
  
          for (int i = 0; i &lt; 100; i++) {
              isPrime(i); 
              outputFile.println("Prime nums are:" + i);
          }
      }
      public static boolean isPrime (int j) {
  
          int i;  
          for (j = 2; j &lt; i; j++) {
              if (i % j == 0) {
                  return false;
              }
              if (i == j) {
                  return true;
              }
          }
      }
  }
  </code></pre>