And by the way add some check for args[] before your code, smth like
class Maxof2{
public static void main(String args[]){
//taking value as command line argument.
//Converting String format to Integer value
* if(args.length > 0){*
int i = Integer.parseInt(args[0]);
int j = Integer.parseInt(args[1]);
if(i > j)
System.out.println(i+" is greater than "+j);
else
System.out.println(j+" is greater than "+i);
}
* }*
*else{
System.out.println("Executed with no parameters");
}*
}
2010/1/19 musmir iqbal <[email protected]>
> when i run this code using NetBeans 6.5.1 i get an error
>
>
> class Maxof2{
>
> public static void main(String args[]){
>
> //taking value as command line argument.
>
> //Converting String format to Integer value
>
> int i = Integer.parseInt(args[0]);
>
> int j = Integer.parseInt(args[1]);
>
> if(i > j)
>
> System.out.println(i+" is greater than "+j);
>
> else
>
> System.out.println(j+" is greater than "+i);
>
> }
>
> }
>
>
> this is the error message
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
> at MaxOf2.main(MaxOf2.java:9)
> Java Result: 1
>
> --
> Musmir Iqbal
>
> --
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]<javaprogrammingwithpassion%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
--
--
Sincerely,
Nikita Demeschenko
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en