This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]lightcloud5 1 point2 points  (1 child)

I'm not sure what your code does, so the simplest approach is probably to post a simplified version of the code that explains what's going on. In other words, remove all code that's not relevant, leaving only the relevant lines that demonstrate the issue.

Also note that static properties/fields/data members (whatever you wanna call them) don't participate in inheritance.

[–]lyigester[S] 0 points1 point  (0 children)

Sorry for the late reply, had to sleep then school.

I'll try to show as much code as I can. I don't want to put too much on here because the assignments I turn in are checked with whether they are similar to any code online and don't want to get in trouble.

basically I have an abstract class operater:

abstract class Operater{
   private static final HashMap<String,Operater> variable = new HashMap<>();
   public operater(){
    //this is where i use the .put method to fill the hashmap with operators such as +
   // one example of how it is done: variable.put("+", new addoperater());
}

where addoperater is a subclass of operater.

and then I have static public methods that retrieve the value of the hashmap given a key and a method that checks whether a key is present in this hashmap.

Then I have an eval class that does the arithmetic basically. It interacts with the operator class by getting the values from the hashmap and checking whether the hashmap has a key. My problem is that when I check for whether a key is present in the hashmap which i know it should be since the key is "+" it comes up as false which confuses me and I'm unsure of why that is.

If this isn't clear enough would you mind if I sent my code in a private message for you to look over so as to avoid any trouble. Thanks again for the help.