Swapping without using a third variable
2 posters
LFPS - Forum :: Study Corner :: Computers :: Java :: Snippets
Page 1 of 1
Swapping without using a third variable
- Code:
class Swa_p
{
public static void main(String[] args)
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
a=a+b; //a=6//
b=a-b; //b=2//
a=a-b; //a=4//
System.out.println(a);
System.out.println(b);
}
}
- Code:
E:\Program Files\Java\jdk1.6.0\bin>java Swa_p 12 13
13
12
shirish.vogga- New LSF Member
- Posts : 3
LFPS - Forum :: Study Corner :: Computers :: Java :: Snippets
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Feb 14, 2012 9:02 pm by Sujith
» Kolaveri Di
Tue Nov 22, 2011 5:11 pm by Sujith
» Plane of Remembrance
Mon May 23, 2011 7:44 am by Sujith
» Board Exam Results 2011
Fri May 13, 2011 10:19 pm by Sujith
» Source Code
Wed May 04, 2011 8:06 pm by Sujith
» Rio
Wed May 04, 2011 8:04 pm by Sujith
» Fast and Furious 5
Wed May 04, 2011 7:56 pm by Sujith