Quick question about java....

Ns1

No Lifer
Jun 17, 2001
55,420
1,600
126
I got a question about the increment operator in java

a=1
A++ means that A is now equal to 2, but when does it increment?

ex)

i = 1;
system.out.print(i++);


assuming my syntax is correct

would that print 1, then increase i to 2, or increase i to 2 then print it?

i think i++ would write it first, then increment it, and ++i would increment it, then write it

correct? yes no maybe so????
 

XZeroII

Lifer
Jun 30, 2001
12,572
0
0
That is correct, and it's the same in C++. I hate Java though. I'm taking a class in it and I just plain don't like it. TONS of work to do simple stuff.
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0


<< That is correct, and it's the same in C++. I hate Java though. I'm taking a class in it and I just plain don't like it. TONS of work to do simple stuff. >>



You MUST be kidding?? How much simpler could it possibly be? Java abstracted a great majority of the complexity that you would otherwise incur in C++ by way of their class library.