aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "generics" Watch "generics" New topic
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: 19003
    
  40

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generics