My suggestion for a class would be as follows:
class IdPwPair {
final public String id, password;
public IdPwPair(String id, String password) {
this.id = id;
this.password = password;
}
}
Explanation
What you want to design is a data-holder class. It is strongly recommended to use the final keyword here and not add a setter, because this class does not control the data, only hold it together.
This not only makes accessing the data easier (and faster), it as well allows for a much simpler code structure. Instead of having to track when and where you change the content of a dataset, you just use them and throw them away if they are no longer valid. This ensures that a given set of data at any time either holds the exact one set of information, or doesn't exist anymore. Not even a chance to mess up here by accidentally changing the data while someone else was still using it.
Note: There are security concerns for keeping passwords in JVM memory, because someone could live-hack the JVM and pull out the passwords. So if you are working on a software where this is a concern (which I doubt), you should use char[]
instead and overwrite the content once it is no longer used.