How to swap two String values without using a
third variable?

Answer Posted / bharat

import java.util.Scanner;

public class Swap {

/**
* @param args
*/


public static void main(String[] args) {
// TODO Auto-generated method stub
int a, b;
System.out.println("Enter a and b");
Scanner in = new Scanner(System.in);

a = in.nextInt();
b = in.nextInt();
System.out.println("Befor Swapinng :" + "a : " + a + "\t" + "b :" + b);
b = a + b;
a = b - a;
b = b - a;
System.out.println("a : " + a + "\t" + "b :" + b);

}

}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

diffrence between oracle apps , .NET , SAP

1603


EXPLAIN UNARY OPEARATORS

1800


what do u mean by tagging

1616


hi i am jyoti i have done sap training in sd and master degree in economics have 2 year exp as enduser in (gdms)and 1 year as sd consultant.as contract basis now what i can do for getting job in it industry

1651


hi all, i need ur help in preparing a sql which performs scd2, i mean i have a scd2 mapping i need a sql which can give me same result as scd2 mapping, SRC table: cust_no, loc 01 abc 02 xyz TGT table: pm_ky cust_no loc current_flag 1 01 abc Y 2 02 xyz Y cust 1 has changed his loc to xyz then it loads into TGT table as below, pm_ky cust_no loc current_flag 1 01 abc N 2 02 xyz Y 3 01 xyz Y i need sql to get the above result, hope got me question, Any suggestion will be appreciate.. thanks, Vinod

1642






What is SOLID Principle in Programming Language?

656


what is difference between kpo and it industry? that is in terms of work, package etc

1534


Is buffer size and file block size is similar? If similar,at which case it will be same size?

1736


Can i please VHDL code for D-Latch with clear input ?? (HINT: Set up a “Process” with appropriate sensitivity list to get the desired D-Latch with Clr working.) Inputs and Outputs: entity Lab4b is Port ( Clr, Clk, D : in STD_LOGIC; Q : out STD_LOGIC); end Lab4b;

990


HOW TO FIND NUMBER OF TWOS IN N!(N FACTORIAL)??

1783


How to connect to ms word wit VB ojective is to prepare s/w to generate question paper , selects questions randomly from the ms access , database

2009


i want to insert textbox value to sql db. i have only one text box but store four values. ple give any one give sample code in asp.net c#..

2879


what is web service in java? have u use before.

1627


they asked me about srs (software requirement specifcation)? how can i get anydocumentation about srs & other documnts infomation like bdd, in testing? its urgent?

1452


What is the difference beween joblib and steplib statements

1783