Who knows Java
What the Output to this program?int forgetIt = 0for (i = 2; i <= 7; i++)forgetIt = foregetIt + 3;System.out.println(forgetIt);
i came up with 45 that's still can be correct right?
Run it and see for yourself.If you can't do that, the work through it in your head or on paper and state what you think it is and how you got there.Don't just ask for answers without putting in any effort yourself.
jverda at 2007-7-10 11:17:41 >

> Who knows JavaNobody. We just sit around quoting Monty Python and discussing beer brands.P.S. The answer is 42.
> i came up with 45 that's still can be correct right?No, you must have done something wrong. My answer is correct.P.S. Don't listen to flounder. He doesn't like newbies and he's just trying to mess you up.
> i came up with 45 that's still can be correct right?How did you get that?
jverda at 2007-7-10 11:17:41 >

i came up with 45 by adding the 2 + 1-7 then added the 3 to get 45
> i came up with 45 by adding the 2 + 1-7 then added> the 3 to get 45What?for (int ix = 2; ix <= 7; ix++)Do you know what that means? Do you know how many times the loop body will
jverda at 2007-7-10 11:17:41 >

Do you know what this means? forgetIt = foregetIt + 3;
jverda at 2007-7-10 11:17:41 >

i'm still learning it but i will not give up on it. i want to learn this so bad i know yall understand where i'am right noe being a newbie in the java game.
for (int ix = 2; ix <= 7; ix++)Do you know what that means? Do you know how many times the loop body will execute? http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
jverda at 2007-7-10 11:17:41 >

> i came up with 45 by adding the 2 + 1-7 then added the 3 to get 452 + 1 - 7 + 3 = -1 not 45!
Who knows Java? SH*T I thought this was the COBAL forum... *leave*(and the answer is 42)
thanx Duke's with the help one day i will join ranks as well
> Do you know what this means?forgetIt = foregetIt + 3;Compilation error.
The answer is actually 18!!!!
> Compilation error.Unless he has both forgetIt and foregetIt.
> The answer is actually 18!!!!That was spectacularly unhelpful.
jverda at 2007-7-21 18:40:32 >

Well you guys asked for the answer and i'm just trying to give it. If he wrote the syntax correctly the answer would come out to be 18, am i wrong?if so please explain what i did wrong.
> Well you guys asked for the answer and i'm just
> trying to give it. If he wrote the syntax correctly
> the answer would come out to be 18, am i wrong?
>
> if so please explain what i did wrong.
Whether 18 is the correct result or not is irrelevant. Telling the OP what the result is does not help. Helping him to understand how Java works so he can figure it out on his own does help.
If you're going to just give him the answer (which I think is a bad idea), at least explain why that's the answer.
jverda at 2007-7-21 18:40:32 >

> > Well you guys asked for the answer and i'm just
> > trying to give it. If he wrote the syntax
> correctly
> > the answer would come out to be 18, am i wrong?
> >
> > if so please explain what i did wrong.
>
>
> Whether 18 is the correct result or not is
> irrelevant. Telling the OP what the result is does
> not help. Helping him to understand how Java works so
> he can figure it out on his own does help.
>
> If you're going to just give him the answer (which I
> think is a bad idea), at least explain why that's the
> answer.
Cool i got u. Next time i will let them figure it out, but the reason i posted is because some people were telling him 45 was the correct answer and i did not see how you guys were getting that.
Thanks anyway..
> Cool i got u. Next time i will let them figure it
> out, but the reason i posted is because some people
> were telling him 45 was the correct answer and i did
> not see how you guys were getting that.
I see.
The OP is actually the one who thought 45 was the answer. The other numerical answers that were given were obviously (I thought, anyway) jokes.
jverda at 2007-7-21 18:40:32 >

Would like us to wrap our responses in <sarcasm> tags in the future?
> The OP is actually the one who thought 45 was the> answer. The other numerical answers that were given> were obviously (I thought, anyway) jokes.I wasn't joking. The answer is 45,783,329.;-)
@Jverd and @Programmer: Beautiful to see.- Saish
Saisha at 2007-7-21 18:40:32 >

> What the Output to this program?
>
> int forgetIt = 0
>
> for (i = 2; i <= 7; i++)
>
> forgetIt = foregetIt + 3;
>
> System.out.println(forgetIt);
if there were no compilation error, it would be this:
int forgetIt = 0
for (i = 2; i <= 7; i++)
forgetIt = forgetIt+ 3;
System.out.println(forgetIt);
after 1st loop: i = 3, forgetIt = 3;
after 2nd loop: i = 4, forgetIt = 6;
after 3rd loop: i = 5, forgetIt = 9;
after 4th loop: i = 6, forgetIt = 12;
after 5th loop: i = 7, forgetIt = 15;
after 6th loop: i = 8, forgetIt = 18;
yay.....
man it will bring to you a nice compilation error.
I wish I knew Java... Its a damm worderfull word... Oh Java...MeTitus