Java concept

Program For Swapping of Two No using This Pointer:-




 public class swap1 {

     int a=10,b=20;

     public  swap1(int p,int q)
     {
         this.a=p;
         this.b=q;
     }


 void disp()   {
    System.out.println("p="+b+"q="+a);       
           }
   
         public static void main(String[] args) {
      // TODO Auto-generated method stub
   
 swap1 s=new swap1(10,20);
 s.disp();


    
      

     }
 }

No comments:

Post a Comment