Claudio Lopez Claudio Lopez -5 years ago 86
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?

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download