Originally posted by jignesh soni:
In c and C++, it was possible to return more than one values from a method with the help of pointers. How can we return more than 1 values from a method in Java, as this is pass by value only and no pointers are used ?
I think, it is very poor design to create classes so that a method can return more than one value. Java is Object Oriented, so design it that way. Your objects (and thereby classes) are more important than any of your methods within them. Maybe your function is trying to do too much, or else,what you really need is a collection/array.
If the two values are completely unrelated, then it is indeed the question whether or not your design can be improved.
However, having multiple side effects to a method is almost always a bad design.
you should first question your design, then use the above functionality. As mentioned above, this may be directing you to define a new type of object.