java Generics legacy compitability problem -
This code is compiled properly and when "004b" is executed, then how does it happen? Does a classcastException
Public static zero enclosed (list list) {list.add ("004b"); } Public static zero main (string [] args) {List & lt; Integer & gt; IntList = New Arrestist & lt; Integer & gt; (); IntList; Println (intList.get (0)); }
Tip:
- Do not mix crude And general typing
- Turn on the usual type of warnings of your Java compiler, it will tell you about your useless code.
- If you use the "checked archive" type (for example created using the archive. Checked List (...)) Exception if you type incorrectly Find the object in the collection.
Comments
Post a Comment