Java - Swap two numbers without using temp variable

Veröffentlicht am: 21 November 2020
auf dem Kanal: Legendary Computer Programmer
23
1

Welcome to my channel. Please Subscribe, like and share.
It is greatly appreciated.

#legendaryprogrammer

import java.util.*;
import java.lang.*;

CODE:

class Rextester
{
public static void main(String args[])
{
int x = 10;
int y = 15;

x = x + y; // 25 temp x

y = x - y; // 25 - 15 = 10
x = x - y; // 25 - 10 = 15

System.out.println("x = " + x);
System.out.print("y = " + y);
}
}

END CODE

Are you struggling with coding such as C++, android or java. Look no further. I got you. Compilers are annoying and can drive us mad, wasting hours trying to find the answer that could be a as simple as a comma. That's why I'm here. To save you time and headache. Subscribe to my channel so you can rest easy. Spread the word far and wide that programmers united does not have to worry!

If you have any requests or suggestions, let me know in the comments. Thanks :)


Auf dieser Seite können Sie das Online-Video Java - Swap two numbers without using temp variable mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Legendary Computer Programmer 21 November 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 23 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!