I want to return two values from a method stored in an array. How can I do it?
For example: The method needs to return "un" and "pwd".
A tidy and Javaesque way to return multiple values is to create an object to return them in, e.g.
public class Whatever {
public String getUn() { return m_un; }
public String setUn(String un) { m_un = un; }
public String getPwd() { return m_pwd; }
public String setPwd(String pwd) { m_pwd = pwd; }
};
public Whatever getWhatever() {
Whatever ret = new Whatever();
...
ret.setPwd(...);
ret.setUn(...);
...
return ret;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With