New to java. Unclear about this piece of code:
ParseQuery query = new ParseQuery("GameScore");
query.getInBackground("xWMyZ4YEGZ", new GetCallback() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
// object will be your game score
} else {
// something went wrong
}
}
});
With new GetCallback() {....}, is it instancing an instance of GetCallback class or defining a subclass of Getcallback class or both?
Is this Java’s way of doing anonymous functions in C/Objective-C and Ruby’s blocks?
It’s doing both. It’s declaring an anonymous inner class (you’ll see a corresponding .class file in the compiled output) and creating a new instance of it.
Java doesn’t have a way of creating just an anonymous function (as of Java 7) – this is as close as it gets though.