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 7173749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:53:22+00:00 2026-05-28T15:53:22+00:00

Recently, I ran into a mysterious problem in an android project, which I described

  • 0

Recently, I ran into a mysterious problem in an android project, which I described here. I somehow solved the problem, but still don’t know the exact reason behind it.

Let’s say I want to call a function foo() in the inner class. The question is, what’s the difference between calling it directly like

foo();

or calling it with the outer class instance

OuterClass.this.foo();

Besides, i will appreciate if anyone can check my last question related to this, and give me a clue about why the error occurs. Many thanks.

PS: I read somewhere that the non-static inner class will always hold an instance of the outer class. So it will call outer function using that instance if I only use foo()?

  • 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-05-28T15:53:24+00:00Added an answer on May 28, 2026 at 3:53 pm

    The latter is more explicit and will allow you to call the outer class method if one exists in the inner class with the same name.

    class OuterClass {
        void foo() { System.out.println("Outer foo"); }
    
        View.OnClickListener mListener1 = new View.OnClickListener() {
            void foo() { System.out.println("Inner foo"); }
    
            @Override public void onClick(View view) {
                foo(); //Calls inner foo
                OuterClass.this.foo(); //Calls outer foo
            }
        }
    
        View.OnClickListener mListener2 = new View.OnClickListener() {
            @Override public void onClick(View view) {
                foo(); //Calls outer foo
                OuterClass.this.foo(); //Calls outer foo
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently ran into a problem with my app, On most android phones I
I recently ran into a problem that I thought boost::lambda or boost::phoenix could help
I recently ran into a problem with a COM object that was using a
A problem I recently ran into was that when trying to update a field
I'm writing a C parser using PLY, and recently ran into a problem. This
I recently ran into a quite complex problem and after looking around a lot
I recently ran into an issue at work in which, at least according to
I recently ran into a situation in which accessing session information from view is
I recently ran into a problem caused by using fstream::eof(). I read the following
I've recently ran into some code that checks Page.IsCallBack but I wasn't sure how

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.