• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exceptions

 
prans rao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi vijayguptha Guptha
you came with fine answer
I have tried as you said
Thatis I have passed arguments like "java cbr 12 24" at runtime.

and i am succeded

THANKS A LOT




import java.io.*;
class cbr
{
int a,b;
void read(int x,int y)
{
a=x;
b=y;
}
void swap(cbr x1)
{
int t=x1.a;
x1.a=x1.b;
x1.b=t;
}
void display()
{
System.out.println(a+" "+b);
}
public static void main(String []s)
{
cbr c=new cbr();
int a1=Integer.parseInt(s[0]);
int a2=Integer.parseInt(s[1]);
c.read(a1,a2);
System.out.println("Before swap");
c.display();
System.out.println("After swap");
c.swap(c);
c.display();
}
}
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is the reply to someones thread , then please post it into the same thread . no need to create irrelevant post .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!