title: unable to access variable outside the while loop in java
body: <p>In this code I am trying to find maximum of n numbers.
  I have declared maximum outside loop, but unable to access the maximum
  variable later:</p>
  
  <pre><code>public class MaxOfNnumbers {
  
      public static void main(String[] args) throws Exception {
          BufferedReader reader = new BufferedReader(new InputStreamReader (System.in));
          int maximum  = Integer.parseInt(reader.readLine ());
  
          //write your code here
          while(true) {
              String s = reader.readLine ();
              int n = Integer.parseInt ( s );
  
              if (n &gt; 0) {
                  if (n &gt; maximum) {
                      n = maximum;
                  }
              }
  
          }
          System.out.println ( maximum );// Error indicates that , maximum variable is unreachable
      }
  }
  </code></pre>