Java Program to Swap a Number

Discussion DashboardCategory: JavaJava Program to Swap a Number
DHARMEDRA SAHU Staff asked 6 years ago
1 Answers
DHARMEDRA SAHU Staff answered 6 years ago

package com.dharma.corejava;

public class SwapNumber {
public static void main(String[] args){
System.out.println(“Swap Number”);
int a = 2147483647;
int b = 30;
System.out.println(“Number(S) before swaping — a: “+a+” b: “+b);
a = a+b;
b = a-b;
a = a-b;
System.out.println(“Number(S) after swaping — a: “+a+” b: “+b);

}

}