# swapping

Umesh
swapping
Posted in : Java Beginners
How to swap values of two variable without using third variable.

Eg: if a=10 b=20

after swap a=20 b=10

May 21, 2010 at 12:04 PM

Hi Friend,

Try the following code:

class Swapping {
public static void main(String[] args) {
int num1 = 10;
int num2 = 20;
num1 = num1 + num2;
num2 = num1 - num2;
num1 = num1 - num2;
System.out.println("After swapping, num1= " + num1 + " and num2= "+ num2);
}
}

Thanks

swapping - Java Beginners
swapping   How to swap values of two variable without using third..., Try the following code: class Swapping { public static void main(String... = num1 - num2; num1 = num1 - num2; System.out.println("After swapping, num1
swapping - Java Beginners
;Hi Friend, Try the following code: import java.util.*; class Swapping...; num2=num1-num2; num1=num1-num2; System.out.println("After swapping
swapping - Java Interview Questions
swapping  if input is 123456 then output should be 214365. how to do it using java code?  Hi friend, As your requirement Code to swapping : import java.io.*; public class SwapNumbers { public static void
Dynamically Swapping Images with JavaScript
Dynamically Swapping Images with JavaScript  ... the numbers Swapping in JavaScript and create a  JavaScript program. Image Swapping in JavaScript:- In JavaScript, Numbers Swapping means interchange
Swapping of two numbers
Swapping of two numbers      ... program to calculate swap of two numbers. Swapping is used where  you want... swap the numbers. To swap two numbers first we have to declare a class Swapping
Swapping of two numbers in java
Swapping of two numbers in java In this example we are going to describe swapping of two numbers in java  without using the third number in java. We... values from the command prompt. The swapping of two numbers is based on simple
Swapping of two numbers without using third variable
Swapping of two numbers without using third variable In this tutorial we will learn about swapping of two number in java without using third variable. This is simple program to swap two value using arithmetic operation Swapping of two
Bubble Sort in Java
is sorted. Swapping is followed carried out repeatedly till the list is sorted. Bubble..., it goes back to first pair. The process of comparing, swapping and returning to first
JAVA PROGRAMMING
JAVA PROGRAMMING  Write an OVERLOADED FUNCTION in java that swaps(interchanges) 2 user given numbers.(one integer and one float value) and displays the result after swapping. Invoke the function in a class
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2] = {2,3}; printf("before swapping: %d %d\n",a[0],a[1]); //a[0] ^= a[1]; //a[1...] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2] = {2,3}; printf("before swapping: %d %d\n",a[0],a[1]); //a[0] ^= a[1]; //a[1...] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n
PHP Call By Reference
"<b>Before swapping values are \\$var1= \$var1 & \\$var2= \$var2... swapping values are \\$var1= \$var1 & \\$var2= \$var2 <br/></b>"; ?> Output: Before swapping values \$var1= 34 & \$var2= 90
function arguments in java
code   public class Swapping{ static void swap(int i,int j){ int temp=i; i=j; j=temp; System.out.println("After swapping i = " + i + " j...; System.out.prinln("Before swapping i="+i+" j="+j); swap(i,j
Swap two numbers without using third variable
: import java.util.*; class Swapping { public static void main(String[] args...; num1 = num1 - num2; System.out.println("After swapping, num1= " + num1...: 20 Enter Number 2: 10 After swapping, num1=10 and num2=20
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2] = {2,3}; printf("before swapping: %d %d\n",a[0],a[1]); //a[0] ^= a[1]; //a[1...] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n
Program to swap the string
(); System.out.println(); System.out.println("Before swapping...("After swapping:"); System.out.println("st1="+st1+" and st2="+st2
java - Java Beginners
: class Swapping { public static void main(String[] args) { int num1 = 10... - num2; System.out.println("After swapping, num1= " + num1 + " and num2
java - JSP-Servlet
place. thanks!!  Hello Without swapping u can pay money
java
pament in my account through A.T.M. tranjections or swapping machin.could u give
JDBC
selection?   public class Swapping{ static void swap(int i,int j){ int temp=i; i=j; j=temp; System.out.println("After swapping i = " + i + " j...; System.out.prinln("Before swapping i="+i+" j="+j); swap(i,j
confusion
, 1)For swapping, use following code: int num1=5,num2=10; num1 = num1
Remove From Super View - removeFromSuperview
it again (in case of swapping views) you required to retain it before calling
Core Java Doubts - Java Beginners
; Hi Friend, 1) class Swapping { public static void main(String[] args... - num2; num1 = num1 - num2; System.out.println("After swapping, num1= " + num1
Working with java Collections class
); System.out.println("List after swapping : " + list); // Replace... swapping : [replaced, replaced, girish, vineet, amit] fill all 'mahendra' in list
What is D2D?
sort of tape. D2D including SATA RAID also provides hot swapping. So D2D has
Java Script With Links and Images
that need to be edited to create JavaScript image swapping.  The JavaScript
10 Unusual Technologies to Come in a Big Way
to wearable electronics and internet ready garments to paying bills by swapping... do all your monetary transactions by just swapping your cell phone against... your cell phone instead of punching or swapping your cards. In any case if once
What is Android Technology?
through real-world action based movements like tapping, swapping, pinching, finger
Sitemap Java Script Tutorial
with JavaScript | Dynamically swapping the images with JavaScript | JavaScript
JavaScript - JavaScript Tutorial
; Dynamically swapping the images with JavaScript In this lesson you
Tutorials