• Post Reply Bookmark Topic Watch Topic
  • New Topic

The final local variable resultDetails cannot be assigned, since it is defined in an enclosing type  RSS feed

 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi getting compilation error on highlighted place.
 
Myyron Murray Latorilla
Ranch Hand
Posts: 65
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only assign once on a final variable.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of directly trying to assign to resultDetails inside the anonymous inner class, you should just return the value from the call() method:

Note that you get a Future, you get the result on the outside by calling get() on the Future (note, this will make the current thread wait until the task has been executed).
 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper.

I need to return resultDetails only.
Please suggest how to return those value
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a reason why you are calling the method callA() in a Callable task? If not, then just get rid of that whole thing:

If there is some reason why you need it to be done in a Callable, then make the Callable return the right thing:

Then get the result from the future:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!