Since type variables don�t exist at run time, there is no way to determine what the
actual array type would be.
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Originally posted by Nicholas Cheung:
Because your just allocate <T> to null, without *new*ing it?
Nick
List<String> names = new ArrayList<String>();
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Originally posted by Nicholas Cheung:
But in another thread, I saw the author quote this example:
I guess the problem might be you cannot new a list, because it is an interface, while you can new concrete class?
Nick
Originally posted by Pradeep Bhat:
complies but
doesn't. I know why the 2nd one does not compile but why does the first code compile.
[ November 16, 2004: Message edited by: Pradeep Bhat ]
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
I think, it's not make sense...
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Originally posted by somkiat puisungnoen:
complies but
doesn't. I know why the 2nd one does not compile but why does the first code compile.
[ November 16, 2004: Message edited by: Pradeep Bhat ]<hr></blockquote>
Why do want to create array of List ???
I think, it's not make sense...[/QB]
SCJP 6.0
Originally posted by VarunKumar Mallisetty:
Can some one answer this question.
I too came here with the same doubt, but searched the ranch if there is already an existing thread on "Generic Array Creation" error.
I tried this
and got the error: Generic Array Creation.
Can some body please explain why i can't create an array of LinkedLists which can operate on strings.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Tony Morris
Java Q&A (FAQ, Trivia)
Alas, poor Yorick, he knew this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|