Sometimes you want to return multiple values from a function. How is this normally done in Java?
One option is to use an array, like this Python snippet that returns a list or tuple:
value, success = read_unreliably()
if success:
print value
Another option would be to return a hash/dict, like this JavaScript example:
var result = readUnreliably()
if (result.success) {
alert(value);
}
One more would be to create a custom object just for this purpose, like this Java example:
ReadUnreliablyResult result = readUnreliably()
if (result.getSuccess()) {
System.out.println(result.getValue());
}
Of course you can also just use some global variables to store what you need instead of passing things around, but let's just say that's not an option.