aspose file tools*
The moose likes Beginning Java and the fly likes non-static method add(java.lang.Object) cannot be referenced from a static context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "non-static method add(java.lang.Object) cannot be referenced from a static context" Watch "non-static method add(java.lang.Object) cannot be referenced from a static context" New topic
Author

non-static method add(java.lang.Object) cannot be referenced from a static context

Carrie Hadler
Greenhorn

Joined: Jun 20, 2002
Posts: 2
Hello. I'm working on a java assignment for school and I keep getting this one error message. My teacher gave us an abstract class that includes two abstract methods and a HashSet. We have to extend the abstract class and define these methods. When I try a command like:
HashSet.add(new apple())
or
HashSet.size()
in one of the methods I am defning, I get these errors:
non-static method add(java.lang.Object) cannot be referenced from a static context
non-static method size() cannot be referenced from a static context
Does anyone know what's going on?
Carrie Hadler
Greenhorn

Joined: Jun 20, 2002
Posts: 2
Oh nevermind. I misread a variable name. All fixed now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: non-static method add(java.lang.Object) cannot be referenced from a static context