About 658,000 results
Open links in new tab
  1. Java Program to Swap two Variables - GeeksforGeeks

    Jul 2, 2024 · Given two numbers x and y, we need to swap their values. In this article, we will learn the Swapping of two numbers in Java. Examples of Swapping Input : x = 10, y = 20; …

  2. Java: Swap two variables - w3resource

    May 12, 2025 · Write a Java program to swap two variables. Java: Swapping two variables. Swapping two variables refers to mutually exchanging the values of the variables. Generally, …

  3. Java Program to Swap Two Numbers - GeeksforGeeks

    Sep 30, 2024 · Given string str, the task is to write a Java program to swap the pairs of characters of a string. If the string contains an odd number of characters then the last character remains …

  4. Java Program to Swap Two Numbers

    In this program, you'll learn two techniques to swap two numbers in Java. The first one uses a temporary variable for swapping, while the second one doesn't use any temporary variables.

  5. Swap Two Variables in Java - Baeldung

    Feb 14, 2025 · In this article, we looked at how to swap two variables in Java, depending on the type of the variables. We described how to swap Objects, and then we studied several ways to …

  6. Is it possible to swap two variables in Java? - Stack Overflow

    May 1, 2012 · You can, however, if x and y hold references to objects, change the properties of the two objects in such a way as to make the printed values look like each other's initial …

  7. How to write a basic swap function in Java - Stack Overflow

    Here's a method to swap two variables in java in just one line using bitwise XOR(^) operator. class Swap { public static void main (String[] args) { int x = 5, y = 10; x = x ^ y ^ (y = x); …

  8. Mastering Variable Swapping in Java: A Comprehensive Guide

    This tutorial will delve deep into various methods to swap two variables in Java, catering to both beginners and experienced developers. We will explore basic techniques, as well as some …

  9. Java program to swap two values - Programmingoneonone

    Jul 31, 2024 · In this tutorial, we are going to write a Java program to swap two values in Java Programming with practical program code and step-by-step full complete explanation.

  10. java - swap two numbers using call by reference - Stack Overflow

    Feb 20, 2012 · Recently when I came across swapping two numbers in Java I wrote. class Swap{ int a,b; void getNos(){ System.out.println("input nos"); a = scan.nextInt(); b = scan.nextInt(); // …

  11. Some results have been removed