R
richnjones
Hi all,
I have only started programming recently and am interested in some of
the "tips n tricks" that can be used in programming. What made me think
about this is the following post
http://groups.google.co.uk/group/co...e8bce6bf65c/7244e048850c4991#7244e048850c4991
It describes how to swap two integers using the xor operation to remove
the need of an extra variable.
I have also seen the modulus operator used to loop through a set number
of integers.
eg to print out 1,2,3,1,2,3,1,2,3 .....
int i = 0;
%start of loop%
system.out.println(i++ % 3);
%end of loop%
My question is: are there any other quick fixes that people may know
of. I know this is quite an open question but any hints/resources would
be good.
Thanks in advance
Richard
I have only started programming recently and am interested in some of
the "tips n tricks" that can be used in programming. What made me think
about this is the following post
http://groups.google.co.uk/group/co...e8bce6bf65c/7244e048850c4991#7244e048850c4991
It describes how to swap two integers using the xor operation to remove
the need of an extra variable.
I have also seen the modulus operator used to loop through a set number
of integers.
eg to print out 1,2,3,1,2,3,1,2,3 .....
int i = 0;
%start of loop%
system.out.println(i++ % 3);
%end of loop%
My question is: are there any other quick fixes that people may know
of. I know this is quite an open question but any hints/resources would
be good.
Thanks in advance
Richard