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

  • SEARCH
  • Home
  • 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 80569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:19:24+00:00 2026-05-10T21:19:24+00:00

Sorry for the bad title, but I couldn’t think of a better one. I’m

  • 0

Sorry for the bad title, but I couldn’t think of a better one.

I’m having a class A and a class B which is kind of a sub class of A, like so:

(Is there actually a correct name for it? Isn’t ‘sub class’ reserved for inheritance?)

class A {     int i = 0;     class B {         int j = 1;     } }  class Test {     public static void main() {         A a = new A();         B b = a.new B();         A c = ??? b ??? // get 'a' back     } } 

From B every property of A can be accessed, therefore both, a.i and b.i, return 0. Now, I’m wondering whether it’s somehow possible to retrieve the original object of type A out of b, as b contains everything that a contains? Simple casting apparently doesn’t do the trick.

Second one:

class A {      void print() {         System.out.println('This is class A.');     }      class B {         void print() {             // <--- How to access print() of class A (like this.A.print() or smth)?              System.out.println('This is class B.');         }     } } 

You could alternatively also provide me with some good resources on this topic, as I’ve been too stupid to find a good one so far.

Thanks in advance. 🙂

  • 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. 2026-05-10T21:19:24+00:00Added an answer on May 10, 2026 at 9:19 pm

    There doesn’t seem to be a way to access the outer class from outside. But you can do it like this:

    class A {     int i = 0;     class B {         final A outer = A.this;         int j = 1;     } }  class Test {     public static void main() {         A a = new A();         A.B b = a.new B();         A c = b.outer // get 'a' back     } } 

    ClassName.this will be the instance of the outerclass associated with the instance of an inner class.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The data attribute of a shared object can store arbitrary… May 11, 2026 at 11:29 am
  • added an answer The RowID are physical location of the data stored on… May 11, 2026 at 11:29 am
  • added an answer This is a known deficiency in MySQL. It is often… May 11, 2026 at 11:29 am

Related Questions

Sorry for the bad title, but I couldn't think of a better one. I'm
Sorry for the basic question - I'm a .NET developer and don't have much
Sorry for the second newbie question, I'm a developer not a sysadmin so this
Sorry for the long question title. I guess I'm on to a loser on
Sorry for the Windows developers out there, this solution is for Macs only. This
Sorry for the slightly rubbish title. I could not think how to describe this
Sorry for the simple question but I feel like there's a smarter way to
Sorry for the slightly noobish question, as I am writing my first rails app.
Sorry in advance for the long question. What I'm really interested in is a
Sorry for my ignorance here, but when I hear the word webserver, I immediately

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.