Claudio Lopez Claudio Lopez - 4 months ago 6x
Java Question

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

I hope you are fine! A bit help needed here.

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? if, yes. HOW?


There are multiple ways, one is given below:

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