Welcome to the Ranch
Code tags are supposed to work when you put [code=java] before your code and and [/code] after it. Also keep your lines short, as it says here. don’t worry, I have sorted it out for you and you can see how much better it looks
Also please tell us what the problem is. If we don’t know, we can’t help you. In this case, I think the compiler is telling you off and you never get near running the code at all.
Your swapping class won’t do what you expect. You have two fields, which you never use.
You have some poor style, too. apart from using tabs for indenting, you have put the  for an array in the wrong place. Put the  before the name of the parameter and then you can see the type correctly. Not Swap obj. Then you will be able to see the type that the compiler thinks you are trying to pass. It doesn’t matter what you think you are trying to pass, it is whether you can convince the compiler of it.
Don’t write a swap method which swaps elements 0 and 1. Write a swap method which takes two ints, remembering you will suffer an Exception if the numbers are inappropriate
pratik gaurav wrote:swapping to two object using call by refrence.
Let's back up.
What are you trying to do Pratik? And explain it to us in English, not in Java. What is your Swap class intended to accomplish?
Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
Joined: Oct 13, 2005
If you mean swapping two elements in an array, that is something different. You are not given the two objects, but one different object—the array. You are not so much swapping as altering the state of the array. Which you can do in a method which is passed a mutable object.
pratik gaurav wrote:please look at it you will come to know what i am trying to explain
If you want to get the most from this site, you should probably read our FAQ on HowToAskQuestionsOnJavaRanch (<---that is a link - click it). But in brief, you want to make it as easy as possible for people to help you. Saying "read the code I posted" is lazy, and turns a lot of people off from helping you.
Instead, if you said "well, I'm trying to swap two objects in memory. I wrote the above code, but I think it doesn't work because....", folks will know they are answering you question instead of guessing what that question is.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors