Home > Back-end >  The great god, how to understand the following code?
The great god, how to understand the following code?

Time:12-09

 
The class Convert {
List ListT=new ArrayList<> (a);
The public & lt; K> Convert ConvertTo (Class CLZ) {
List ListK=new ArrayList<> (a);
ListT=(List) ListK;
Return (Convert) This;
}
}

The corresponding code: "listT=(List) ListK;" From the generic class in real business in addition to implement the Serializable interface, has nothing to do, why don't you error types can turn off, normal operation,

CodePudding user response:

You can see this post:
https://blog.csdn.net/youanyyou/article/details/100910242

CodePudding user response:

The
refer to the original poster BigBox124 response:
corresponding code: "listT=(List) ListK;" From the generic class in real business in addition to implement the Serializable interface, has nothing to do, why don't you report errors of different types can turn off, normal execution,



I think this is the same kind of generic conversion between, of course, since it is generic in a class or K class logically sure no problem,

CodePudding user response:

I know, because of the generic erasure of
  • Related