• Advertisement
Sign in to follow this  

[Java]returning an ordered pair

This topic is 4738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

this is in Java: thi might be kinda stupid, but what's the simplest way to return a pair of integers? Should i put them into a 1D array and return the array? thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
That seems like the most straightforward route.

public int [] doSomething() 
{
int [] blah = new int[ 2 ];

blah[ 0 ] = 8;
blah[ 1 ] = 4;

return ( blah );
}


Or I guess you could wrap them in a class:

class CIntPair {
int one, two;
}

public CIntPair doSomething()
{
CIntPair blah = new CIntPair();

blah.one = 8;
blah.two = 4;

return blah;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement