Gula,
your post can be answered by my post above and radhika post.
a=1
System.out.println(++a +" "+ a++);
is like saying
System.out.println(preincrement to make
2 add a
string space then add a which is
2); now increment a to get 3, but I am outside the parenthesis, so I don't get seen.
answer 22
two:
a = 1;
System.out.println(a++ + " " + ++a);
System.out.println(
1 then increment but add a string space, you had the new value of 2 but preincrement a to
3);
answer 13
when you add a string to an int, the int gets promoted to a string.
but watch out for
a = 2;
b = 2;
System.out.println("."+a + b + " rifle"); //.4 rifle
but
System.out.println("."+a+ ""+b+ " rifle"); //.22 rifle
I hope this helps Gula.
Davy
[ July 14, 2004: Message edited by: Davy Kelly ]