File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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.
 
 
subject: non-static method add(java.lang.Object) cannot be referenced from a static context
 
Similar Threads
Lucene - get TermVector positions
Mock Question (Help)
static
Inheritance Hierarchy??
non-static method init() cannot be referenced from a static context