| Author |
generics
|
Abhishek Bhat
Greenhorn
Joined: Jan 01, 2009
Posts: 25
|
|
This generics has endless secrets...
Why does it give this error :
non-static class String cannot be referenced from a static context
public static void main(String args[])
|
 |
Punit Singh
Ranch Hand
Joined: Oct 16, 2008
Posts: 952
|
|
No you are using something like this:
Got any idea? Or I need to say some more.
|
SCJP 6
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16687
|
|
Would the error make more sense, if it was written like this?
You have confused the compiler. Your first "String" is actually a type. And your second "String" is the java.lang.String class.
[EDIT: Second to the answer again !! ]
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Abhishek Bhat
Greenhorn
Joined: Jan 01, 2009
Posts: 25
|
|
Hi Punit,
My attempt to do that was in the line of the <T> concept only...i was testing using all the different Types....the error however was not expected
The rule is ok but the Type conflict is bizzare with the "main" method argument...
Thanks anyway Punit and Henry ... Thanks a lot
|
 |
 |
|
|
subject: generics
|
|
|