Google+ Followers


Get Updates Via Email

Enter your email address:

Delivered by FeedBurner

Sunday, 10 November 2013

Java Program: Swap two numbers without temp variable

public class Swapwithouttemp {
    public static void main(String[] args) throws IOException
        System.out.println("Enter first number");
        BufferedReader br=new BufferedReader(new InputStreamReader(;
        int x=Integer.parseInt(br.readLine());    
        System.out.println("Enter second number");
        BufferedReader brr=new BufferedReader(new InputStreamReader(;
        int y=Integer.parseInt(brr.readLine());        
        new swap(x,y);
class swap
    swap(int a, int b) throws IOException          
        System.out.println("Before swapped values a= "+a+"\tb= "+b );
        System.out.println("After swapped values a= "+a+"\tb= "+b );

1 comment :

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes


Share this to your friends