Results 1 to 3 of 3
  1. #1
    orchid's Avatar
    orchid is offline Member
    Join Date
    Apr 2007
    Location
    Midwest
    Posts
    60
    Rep Power
    0

    Default Inner class problems

    This will not compile for me. It looks like it should..????
    Java Code:
    public class Outer {
        class Inner1 extends Outer {
            public Inner1()
            {
                super();
            }
            
        }
        class Inner2 extends Inner1 {
            public Inner2()
            {
                super();
            }
            
        }
    }

  2. #2
    pegitha is offline Member
    Join Date
    Apr 2007
    Location
    Indiana
    Posts
    83
    Rep Power
    0

    Default

    This will fix the compilation issue:
    Java Code:
    class Inner2 extends Inner1 {
        public Inner2()
        {
            Outer.this.super();
         }      
      }

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Better if you can simply explain a little with the answer pal. ;)

    Reason is, super(); in Inner2 class cannot refer before the Outer class constructor call, because it's the super class. Inner2 class extend Outer there. Hope it's clear.

Similar Threads

  1. Replies: 0
    Last Post: 04-02-2008, 07:04 AM
  2. Replies: 0
    Last Post: 02-17-2008, 09:03 AM
  3. Inner class accessing outer class
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-17-2008, 08:59 AM
  4. problems with class Splashscreen in netbeans
    By ernieBob in forum NetBeans
    Replies: 0
    Last Post: 02-07-2008, 01:30 AM
  5. Problems in running client class
    By ai_2007 in forum Advanced Java
    Replies: 0
    Last Post: 06-30-2007, 02:57 PM

Posting Permissions

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