Page 1 of 1
About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Mon Sep 24, 2012 9:01 am
by Michailangelo
I don't see the args[2] reference in the code.
Re: About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Mon Sep 24, 2012 9:09 am
by admin
Code: Select all
int i = Integer.parseInt(args[1]);
System.out.println(args[i]);
args[1] is 2
so i is 2
therefore, args
is args[2]
HTH,
Paul.
Re: About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Mon Sep 24, 2012 9:29 am
by Michailangelo
I should pay more attention

.
Re: About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Wed Feb 13, 2013 10:16 am
by satar
Yeah, this one got me also
Re: About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Tue Jun 18, 2013 11:00 am
by deepa.patre
I have a basic question,
why is the method name just parseInt() instead of parseInteger()?
Please reply,
Re: About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Tue Jun 18, 2013 11:13 am
by admin
You have to ask Java designers that

Re: About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Wed Apr 15, 2015 7:18 am
by peckw1
If I run the code with 4 and 5 I also get the exception, in this case shouldn't args[0] = 4 and args[1]=5?
Re: About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Wed Apr 15, 2015 10:32 am
by admin
peckw1 wrote:If I run the code with 4 and 5 I also get the exception, in this case shouldn't args[0] = 4 and args[1]=5?
Yes, args[0] = 4 and args[1]=5. But I am not really sure what is your point.
Paul.
Re: About Question enthuware.ocajp.i.v7.2.1242 :
Posted: Sat Jul 11, 2020 4:31 pm
by maltine
System.out.println(i);//2
System.out.println(args
); //i=2, so, args[2] --> throw an exception
Yes, this one got me also.... 