24 March, 2011

java String[], array of String

in java one can return multi variables by return an array of String, String[]

public String[] foo(){
    String[] resultSrtArr = new String[2];    
    resultStrArr[0] = Integer.toString( 321 );
    resultStrArr[1] = "result";
    return resultSrtArr;
}

public toCallFoo(){
    String[] resultSrtArr = foo();
    int a = Integer.parseInt( resultStrArr[0].trim() );
    String str = resultStrArr[1];
}

No comments:

Post a Comment