Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • Thank you Sir, After spending long time trying i came to this point too, I tried mainly to use 2 strategies; 1st is to store the parametrized object in inner static parametrized class as field within a raw class which has parametrized methods to set and get this inner field, but the problem it’s possible to have a static field in a generic class, but you cannot make that static field itself generic in the same way as instance fields Commented Aug 8 at 21:43
  • the 2nd strategy was to store params types then use them to cast or with reflection api help to remake it in its parametrized state but you cant do that dynamically without storing the object to capture its params types otherwise u need manual casting ,so we are back to our initial problem, so im convinced there is no way to do it, maybe thats why java created var but var has some limitation, i appreciate everyone else reply, thank you all Commented Aug 8 at 21:46