title: Can I create a custom object in an interface and define it in an implementing class?
body: <p>I have an interface source code which I must create a class for. The interface includes a user-defined object which is only declared in the interface, and must be overridden and defined in my own class. My class is later used in a separate file with main to call its methods.</p>
  <p>source code (pseudo code):</p>
  <pre><code>package folder1.subfolder;
  
  public interface IObj {
     void setVal(int val);
     int getVal();
     obj someFunc(obj obj2);
     obj anotherFunc();
     ...
  }
  </code></pre>
  <p>I need to write a class which should define obj used in the method declarations in IObj (I know obj should be capitalized, but that's how it was given in the source code). The class file is placed in the same folder that contains folder1, and I don't have any errors importing the package.</p>
  <p>My class (pseudo code):</p>
  <pre><code>import folder.subfolder.*;
  
  public class obj implements IObj {
     private int objValue;
     obj(int val) {
        objValue = val;
     }
     obj() {
        objValue = 0;
     }
     @Override
     public void setVal(int val) {
        this.objValue = val;
     }
     @Override
     public int getVal() {
        return this.objValue;
     }
     @Override
     public obj someFunc(obj obj2) {
        //perform logic on this obj and obj2, return as new obj
     }
     @Override
     public obj anotherFunc() {
        //perform logic on this obj, return as new obj
     }   
     ...
  }
  </code></pre>
  <p>I don't have any errors with the details of the class methods, but I hope this gives an idea of how I'm trying to use the interface in my class.
  When I attempt to compile my class, I get this message:</p>
  <pre><code>IObj.java:9: error: cannot find symbol
    
      obj someFunc(**obj** obj2);
   
    symbol: class obj
    location: interface IObj
  </code></pre>
  <p>I'm assuming this has something to do with how the object isn't a recognized type (like int or float). I've tried including all of the files in a project (I'm using JGrasp), triple checking file location and import code, including the interface in my class file (more of a last ditch attempt), and considered upcasting to the IObj in my obj constructors (although I'm not sure that would work either.)</p>
  <p>I'm wondering if there was a way for the compiler to ignore the object in the interface as it is defined in my class, or if I've missed a step in defining the object in my class which causes an error, or maybe another approach I haven't considered yet! In this case I can't change the source code, so I'm looking for a way to implement the source code in a different way. I appreciate any suggestions!</p>