I am writing a simple java and bash program, but it is not working. Let me know where is wrong.
Bash:
for i in [1..100]; do
echo $i
java prob2 $i
done
Java:
import java.io.*;
public class prob2
{
public static void main( String[] args )
{
int l = args.length;
if ( l == 1 )
{
int num = Integer.parseInt(args[0]);
while ( num != 0 && num != 1)
num = num - 2;
if ( num == 0 )
System.out.println("Even");
else if ( num == 1 )
System.out.println("Odd");
}
}
}
The error I'm getting is:
Exception in thread "main" java.lang.NumberFormatException: For input string: "[1..100]" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:492) at java.lang.Integer.parseInt(Integer.java:527) at prob2.main(prob2.java:10)
[1..100]as a sequence but passes it as only value in the list, tryfor i in $(seq 1 10);.