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].
public class PowerOfTwo{
public static void main(String[] args){
int k = 1;
int n = Integer.parseInt(args[0]);
if(n < 0){
System.out.println("");
}else{
for(int i=1; k <= n; i++){
k *= 2;
if(k <= n){
System.out.println(k);
}else{
System.out.println();
}
}
}
}
}