title: Java - How to parse large int as command line argument?
body: <p>I need to write a short program that works for all values of n. n is a command line argument(args[0]). The problem is Integer.parseInt doesn't work for large values such as 20000000000. What could i do to get around this problem? The program is designed to print all values that are the power of 2 until that value is >= n and n has to be argument[0].</p>
  
  <pre><code>public class PowerOfTwo{
  public static void main(String[] args){
      int k = 1;
      int n = Integer.parseInt(args[0]);
      if(n &lt; 0){
          System.out.println("");
      }else{
          for(int i=1; k &lt;= n; i++){
              k *= 2;
              if(k &lt;= n){
                  System.out.println(k);
              }else{
                  System.out.println();
              }
          }
      }
  }
  </code></pre>
  
  <p>}</p>