Claudio Lopez Claudio Lopez - 1 year ago 51
Java Question

How to implement setters and getters with String and int at the same time?

I know how to "setValue" the "getValue" however how you do "getValue" in this case?

public void setInfo(String name, int age) {

Is there a way to getInfo with string and int at the same time?

Answer Source

There are multiple ways, one is given below:

public Object[] getInfo() {
    Object[] info = new Object[2];
    info[0] = getName();
    info[1] = getAge();
    return info;