[Java]returning an ordered pair
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
That seems like the most straightforward route.
Or I guess you could wrap them in a class:
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;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement