title: Using Interfaces within classes in Java
body: <p>I'm struggling to suss something out with Java. How do I use the method giveCode() to return the integer value for an object. This is code that was pre written by our lecturer, and we have to use it to return an integer value for an object, it's to be used when creating hash values for a hash table.</p>
  
  <p>HashCode.java</p>
  
  <pre><code>// Interface for HashCode. Has only one method declaration
  public interface HashCode {
  
      // For an input object, computes and returns its HashCode as an integer
          public int giveCode(Object o);
  
  }
  </code></pre>
  
  <p>StringHashCode.java (I created this class as we are supposed to implement the HashCode class into this class)</p>
  
  <pre><code>public abstract class StringHashCode implements HashCode{
  
  
  } 
  </code></pre>
  
  <p>I've tried things like this in my main, just to simply return the code value, so I can see how it works, but nothing seems to be working:</p>
  
  <pre><code>System.out.println(new StringHashCode.giveCode(example_object));
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>System.out.println(new StringHashCode.giveCode(example_object.hashCode()));
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>System.out.print(HashCode.giveCode(example_object));
  </code></pre>
  
  <p>I'm quite new to Java, but I have a lot of experience with other OOP languages, but I can't seem to grasp the issue with this one, I feel like it's probably something stupid, but I can't suss it out.</p>