Reputation: 1009
I was trying to experiment with the Dropbox API tutorial, and the following lines of code don't make sense to me:
// This will fail if the user enters an invalid authorization code.
DbxAuthFinish authFinish = webAuth.finish(code);
String accessToken = authFinish.accessToken;
DbxClient client = new DbxClient(config, accessToken);
I don't understand the first line, a new object named authFinish
of type DbxAuthFinish
is being declared and then accessToken
is set equal to authFinish.accessToken
.
If my understanding of the code is correct why isn't the new
keyword required?
Upvotes: 2
Views: 123
Reputation: 16930
The webAuth.finish
method returns an already initialized DbxAuthFinish
instance, so you don't have to include new
in your code. If you look at the source code for the Dropbox Core Java SDK, you'll see that the finish
method in DbxWebAuth
itself concludes with:
return new DbxAuthFinish(finish.accessToken, finish.userId, givenUrlState);
Your code then goes on to pull the access token from the DbxAuthFinish
and use it to initialize a DbxClient
.
Upvotes: 1