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:

  1. Do not mix crude And general typing
  2. Turn on the usual type of warnings of your Java compiler, it will tell you about your useless code.
  3. 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

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -