• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh nevermind. I misread a variable name. All fixed now.
reply
    Bookmark Topic Watch Topic
  • New Topic