Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:26:35+00:00 2026-06-15T03:26:35+00:00

I’ve read about the substitutability of super and this in Java, so that a

  • 0

I’ve read about the substitutability of super and this in Java, so that a reference to super is legal in the same places where this is legal in the superclass (with the exception of the code of class Object, in which super cannot appear). When I put this to the test it seems to fail as shown in the following example:

class OuterSuper {
  public int oneNumber() { return 5; }
  class Inners {}
  int i1 = OuterSuper.this.oneNumber();
  OuterSuper.Inners si1 = OuterSuper.this.new Inners();
}
class Outer extends OuterSuper {
  class Inner {
    int i1 = Outer.this.oneNumber();
    int i2 = Outer.super.oneNumber();
    OuterSuper.Inners si1 = Outer.this.new Inners();
    OuterSuper.Inners si2 = Outer.super.new Inners();
  }
}

The compiler balks at the last declaration, of member si2. In this example, I am able to write declarations for int i1 and i2 and it is just like the specification says, I can replace whatever I pass to super, to this in the superclass. For the inner class I am stuck and have to use this. Is this this a different this? I’m writing “Outer.this” and “Outer.super” in both instances…

I would like to share that I am using javac (the commandline JDK from Oracle 1.6) and NetBeans. The error I get from javac is:

Exe.java:32: <identifier> expected
        OuterSuper.Inners si2 = Outer.super.new Inners();
                                            ^
Exe.java:32: invalid method declaration; return type required
        OuterSuper.Inners si2 = Outer.super.new Inners();
                                                ^
2 errors
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:26:36+00:00Added an answer on June 15, 2026 at 3:26 am

    So, here are my two-cents. I was under the impression that super could only be used in a class to reference its own base class. I didn’t think it was allowed to reference another class’ super even given the inner class relationship. This is because no class other that the class itself should be able to bypass method overriding.

    So, according to the Java Specification:

    It is a compile-time error if the current class is not an inner class of class T or T itself

    Given this, your code should compile.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.