import java.util.*;
class Main
{
int a,b;
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
Main m=new Main();
System.out.println("Enter two number:");
m.a=sc.nextInt();
m.b=sc.nextInt();
System.out.println("Numbers are a="+m.a+"\tb="+m.b);
swap(m.a,m.b);
System.out.println("After returning from method \n numbers are a="+m.a+"\tb="+m.b);
}
static int swap (int a,int b)
{
int temp;
temp=a;
a=b;
b=temp;
System.out.println("After swapping in method\n numbers are a="+a+"\tb="+b);
}
}
class Main
{
int a,b;
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
Main m=new Main();
System.out.println("Enter two number:");
m.a=sc.nextInt();
m.b=sc.nextInt();
System.out.println("Numbers are a="+m.a+"\tb="+m.b);
swap(m.a,m.b);
System.out.println("After returning from method \n numbers are a="+m.a+"\tb="+m.b);
}
static int swap (int a,int b)
{
int temp;
temp=a;
a=b;
b=temp;
System.out.println("After swapping in method\n numbers are a="+a+"\tb="+b);
}
}
No comments :
Post a Comment