Question: > 
> **Possible Duplicate:**  
> 
> [How to return multiple objects from a Java method?](https://stackoverflow.com/questions/457629/how-to-return-multiple-objects-from-a-java-method) 
> 
> 
> 

Is there any way to return multiple defferent objects from a Java method

for example i want return string ,int ,object ,.. etc

thanks

Answer: 
Make a new class and return that class.

```
//Give this a more descriptive name reflecting what it REALLY is.
public static class ReturnData{
protected String foo
protected int bar

public ReturnData(String foo, int Bar) {
  ...
}
String getFoo() {
  ...
}
int getBar() {
  ...
}

```

Then in your method instantiate the object with what you want to return

```
MyMethod(...){
   ...
   ...
   return new ReturnData(foo, bar);
}

```

Viola! You returned both foo and bar at same time.
Not explicitly. You can make your own class that contains eveything, and return that, or you can return some form of `Object` array (`Object[]`) or list (like an `ArrayList`) that contains everything, but that is not recommended.

EDIT: Also you can use generics as mentioned above, this falls under the category of making your own class, thought I would mention it seperately too though.