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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:38:40+00:00 2026-05-15T09:38:40+00:00

I see a lot of java code where android prefers to have developers use

  • 0

I see a lot of java code where android prefers to have developers use static inner classes. Particularly for patterns like the ViewHolder Pattern in custom ListAdapters.

I’m not sure what the differences are between static and non-static classes. I’ve read about it but it doesn’t seem to make sense when concerned with performance or memory-footprint.

  • 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-15T09:38:41+00:00Added an answer on May 15, 2026 at 9:38 am

    It’s not just Android developers…

    A non-static inner class always keeps an implicit reference to the enclosing object. If you don’t need that reference, all it does is cost memory. Consider this:

    class Outer {
        class NonStaticInner {}
        static class StaticInner {}
        public List<Object> foo(){ 
            return Arrays.asList(
                new NonStaticInner(),
                new StaticInner()); 
        }
    }
    

    When you compile it, what you get will be something like this:

    class Outer {
        Outer(){}
        public List<Object> foo(){ 
            return Arrays.asList(
                new Outer$NonStaticInner(this),
                new StaticInner()); 
        }
    }
    class Outer$NonStaticInner {
        private final Outer this$0;
        Outer$NonStaticInner(Outer enclosing) { this$0 = enclosing; }
    }
    class Outer$StaticInner {
        Outer$StaticInner(){}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see a lot of legacy .Net 1.1-style code at work like in example
In most of the Java code that uses collections,i see something like this. List<String>
I have few classes and functions in java code. one of the function is
I see a lot of people are using code under viewDidLoad to be able
I see a lot in autoconf code about stuff being dnl'ed and not dnl'ed.
I see a lot of code similar to the following var customrs = MyDataContext.Customers.Where(...);
I see a lot a similar questions R.java can't compile , No resource found
In a lot of of the Java source, (for example LinkedBlockingDeque ) I see
I'm making an Android app using Processing, and have decided to port my code
I'm writing an application (on android) that uses both java code, and native code.

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.