File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generics

 
Abhishek Bhat
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 952
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No you are using something like this:


Got any idea? Or I need to say some more.
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Abhishek Bhat
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic