Claudio Lopez Claudio Lopez - 7 months ago 13
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?


There are multiple ways, one is given below:

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