swap three variables in java without using temporary variable

Solutions on MaxInterview for swap three variables in java without using temporary variable by the best coders in the world

showing results for - "swap three variables in java without using temporary variable"
Jasmin
10 Oct 2018
1import java.*; 
2  
3class noTemp { 
4  
5    public static void main(String a[]) 
6    { 
7        int x = 10; 
8        int y = 5; 
9        x = x + y; 
10        y = x - y; 
11        x = x - y; 
12        System.out.println("After swaping:"
13                           + " x = " + x + ", y = " + y); 
14    } 
15} 
Vlad
25 Jan 2018
1public class Exercise15 {
2  public static void main(String[] args) {
3     // int, double, float
4   int a, b;
5   a = 15;
6   b = 27;
7   System.out.println("Before swapping : a, b = "+a+", "+ + b);
8   a = a + b;
9   b = a - b;
10   a = a - b;
11   System.out.println("After swapping : a, b = "+a+", "+ + b);
12 }
13 
14}
15
16
Maximilian
28 Mar 2016
1public class Main{public static void main(String[] args) {float a = 3.66f, b = 6.47f;System.out.println("a number " + a);System.out.println("b number " + b);float temp = a;a = b;b = temp;System.out.println("After swapping");System.out.println("a number " + a);System.out.println("b number " + b);}}
Juan Pablo
01 Feb 2016
1// swap three variables in java without using temporary variable
2public class SwapThreeNumbersWithoutTemp
3{
4   static int num1, num2, num3;
5   public static void main(String[] args) 
6   {
7      num1 = 30; num2 = 60; num3 = 90; 
8      System.out.println("Before swapping three numbers: num1 = " + num1 + ", num2 = " + num2 + ", num3 = " + num3);
9      swapWithoutTemporary();
10      System.out.println("After swapping three numbers: num1 = " + num1 + ", num2 = " + num2 + ", num3 = " + num3);
11   }
12   static void swapWithoutTemporary() 
13   { 
14      num1 = num1 + num2 + num3; 
15      num2 = num1 - (num2 + num3); 
16      num3 = num1 - (num2 + num3); 
17      num1 = num1 - (num2 + num3);  
18   }
19}
queries leading to this page
how to swap two values in javahow to make a swap function in javawrite a java program to swap two numbers using the third variable how to swap between 2 values placing in javaswap two values in javaswapping techniques using javaswap two elements in javaswapping two variables without using third variable in javaswapping two numbers using temp in javaswap two numbers in java using functionswapping two numbers for loop javawrite a program to swap two int variables using a temporary variable in javaswap two numbers in java using methodjava how to swap two itemswap variable without temp javajava wap to swap two numbers without using temporary variablejava swap two numbers without using temporary variablehow to swap two numbers without using a third variable in javahow to swap 3 variables in javaswapping two numbers in java 3fswap a and be local variables javaswap numbers in java without using third variablehow to swap two numbers in java without using third variablehow to swap two numbers without using temporary variable in javajava inbuilt function for swapping two valueswrite java programm to swap numbers by mothedsswap two strings without using third variable in javaswap without temp in javaswaping 2 numbers in javaswap method for swapping two elements in javaswap two numbers without using third variable and arithmetic operator in javahow do you swap two integers without using a temporary variable 3fswap three variables in java without using temporary variableswapping two elements in javajava wap to swap two numbers using temporary variable swap value javawrite a java program to swap two variables swap vaule with two variable on javajava program that swaps two numbers using temporary or third variablejava program to swap two numbers without using third variablehow to write swap function in javaswap ints without tempjava program for swapping without third variableswapping of two numbers in java using for loopswap numbers using temporary variables in javahow to change the values of two variables without swapingin javajava program for swapping of two numbersswap 2 numbers without using 3rd variable javaswap two no in javaswap 2 number in javaswap two integers in javaswap two integer in javahow to swap two numbers in java without using temporary variablewrite a java program to swap two numbers without using a third variablewrite a java program to swap two strings using a third variableswapping of 2 numbers without using 3rd variable in javahow to swap two variables in javaswap tw in javawrite a java program to swap the value of two variables without using third variableswap of two numbers in java using swap functionjava swap variablesjava switch swap variablesswapp using three variable in javaswap 2 integers in javaswap values in java without third variableswapping of two numbers in java with temporary variableswap 2 element in javawrite a program to swap two int variables without using a temporary variable in javajava swap two variables without using thirdswap two numbers without using third variablejava program to swap numbers without using third variableswapping two numbers without third variable javaswap two numbers in jabahow to swap the values of two objects in javacan you make a function to swap two numbers in javaswap value of two numbers in javaswap function in java without third variablewap to swap two numbers without using third variable in javaswapping of two strings without using third variable in javaswap numbers without temp in javajava swap two variablesswapping numbers without temp variable in javatemporary variable java to swap valueswrite a java program to swap 2 numbersan array swapp two elements using java 3fswap two numbers using function in javaswapping of two numbers using function in javaswap no without using third variable javawrite a program to swap two numbers without using third variable in javajava swap without third variableswapping two numbers without temporary variable in javaswapping two integers without temporary variableswapping of two numbers in javaswap 2 numbers without 3rd variable javajava swap variablejava swap 2 number by methodswap 2 variables javaswapping of two numbers using third variable in javaswapping 2 numbers function in javaswap without third variable in javahow to swap 2 value in javaswapping of two numbers in java without temporary variableswap two numbers in javaswap two numbers in java without using third variable in javaswap 2 item javawap to swap two numbers in javaswap two values javojava swap two variablesswapping of two numbers in java without operatoewrite a java program to swap two numbers without using third variablehow do you swap two variables without using a third variable javaswap value without third variable and with out 2b or javaswapping two numbers without third variable in javaswap primitive type javajava swap function for 2 variablesjava swap variable valuesswap two numbers without using third variable in javaswap two values without third variable in javaswap values of two variables javahow to swap the values of two variables while using objects in javaswap two integer class value in javaswap 2 numbers using xorhow to swap two variables without using third variable in javahow to swap variables javahow to change the values of two variables without swaping in javaswap 3 numbers without temp using javahow to swap two numbers in java without using tempswap numbers without using third variable in javajava program to swap 2 numbers with using third variableswap two strings without using third variable in javahow to swap two variables without using third variable java swap two variables javaswapping without using third variable in javawithout using third variable swapping in javahow to switch or swap value of two variables in javawrite java code to swap two numbers without using a temporary variableswap variables without temp javaswapping without third variable in javahow to swap two variables without using temp in javavariable swap function in javaswap variables method in javaswap in java examplehow to swipe two intergers without using a temporary variablejava function for swapping two valuesswap vaibles method in javaswapping of two numbers without using third variable in javajava wap to swap two numbers using temporary variableswap variables javaallintitle 3aswap three variables in java without using temporary variableswap two variables in javajava swap to variablesswapping two numbers in java without using third variableswap two numbers in java using call by referenceswapping in java using functionswap fuction in javaswap 2 numbers without using 3rd variable in javahow to swap variables in javaswap two numbers in java without using third variableswap tow var in javaswapping in javaswap two values in java usin methidgswap two variables without temporary javaswap two variables without using third variable in javaswap two numbers in java as a functionwap in java to swap two numbers without using third variablehow to swap 2 values in javajava program swap of 2 variables without using thirdswapping of two numbers in java without third variableswap two int without using third user defined variable in javaswap 2 variables without using 3rd variable in javaswap the values of two variables without using third variable in javaswapping variable in java using methodhow to swap two numbers in java without third variablehow to swap without using third variable in javaswap two numbers without third variable in javaswap two int value in javaswap three variables in java without using temporary variable