Results 1 to 4 of 4
  1. #1
    XmisterIS is offline Member
    Join Date
    Aug 2010
    Posts
    35
    Rep Power
    0

    Default ***FIXED I don't understand the error ... (help!)

    I have two classes as follows:

    Java Code:
    class MyClass
    {
      public class MyInnerClass
      {
        ...
      }
    
      ...
    }
    and

    Java Code:
    class MyOtherClass
    {
      public class MySpecialInnerClass extends MyClass.MyInnerClass
      {
        ...
      }
    
      ...
    }
    But when I compile I get the following error: "an enclosing instance that contains MyClass.MyInnerClass is required".

    What am I doing wrong?

    Thanks in advance :)

    EDIT: I fixed it, no worries.
    Last edited by XmisterIS; 09-01-2010 at 04:16 PM. Reason: I fixed it.

  2. #2
    siva_vs_siva is offline Member
    Join Date
    Aug 2010
    Posts
    31
    Rep Power
    0

    Default

    class MyClass
    {
    public static class MyInnerClass //static keyword missing
    {
    ...
    }

    ...
    }

    class MyOtherClass
    {
    public class MySpecialInnerClass extends MyClass.MyInnerClass
    {
    ...
    }

    ...
    }

  3. #3
    siva_vs_siva is offline Member
    Join Date
    Aug 2010
    Posts
    31
    Rep Power
    0

    Default

    Example:

    /*class 1*/
    public class search extends twodimension.inner
    {
    public static void main(String args[])
    {
    display();
    }

    }

    /*class 2*/


    public class twodimension {

    public static class inner
    {
    public static void display()
    {

    System.out.println("Hai to all..");

    }}}

  4. #4
    XmisterIS is offline Member
    Join Date
    Aug 2010
    Posts
    35
    Rep Power
    0

    Default

    Thanks for your reply Siva; it turns out that what I was trying to do was actually best solved using an interface. Many thanks.

Similar Threads

  1. cant understand what this means
    By hasysf in forum New To Java
    Replies: 19
    Last Post: 09-05-2009, 05:27 PM
  2. I don´t understand
    By Manikyr in forum New To Java
    Replies: 6
    Last Post: 02-23-2009, 12:22 AM
  3. [SOLVED] Please help me understand...
    By Master Zero in forum Java Applets
    Replies: 6
    Last Post: 05-05-2008, 08:41 PM
  4. Errors I don't understand
    By MattyB in forum New To Java
    Replies: 4
    Last Post: 04-02-2008, 12:55 AM
  5. i don understand this error
    By Deon in forum New To Java
    Replies: 4
    Last Post: 01-12-2008, 11:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •