[Java]returning an ordered pair

Started by
0 comments, last by Doggan 19 years, 2 months ago
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
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;}

This topic is closed to new replies.

Advertisement