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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:55:00+00:00 2026-05-27T22:55:00+00:00

Hey I’m making a quiz application and I need to pass an ArrayList of

  • 0

Hey I’m making a quiz application and I need to pass an ArrayList of up to 100 “Question” objects from one activity to another. The Question objects have about 6 parameters to them – all pretty small strings. I was looking up ways to do this and one of them mentioned was to declare it as a public static variable in one class and then reference it in another. I was wondering about the following:

  • Do I need to “instantiate” the ArrayList before I can use it or can I just declare the variable? As in:

    ArrayList<Question> QuestionBank = new ArrayList<Question>();
    

    or

    ArrayList<Question> QuestionBank;
    
  • if i’m declaring this variable in one activity how does it stay available when I’m in the other activity? Is the activity it was declared in kept running?

  • is this a very memory-consuming method? Is there a more efficient but relatively straight forward way?
  • if I declare the variable null after I finish using it, it will free up all the space that was previously being used right?
  • 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-27T22:55:01+00:00Added an answer on May 27, 2026 at 10:55 pm

    Answers:

    1. You need to instantiate it before you “use” if. By “use” I mean call methods on it. It does not matter where you instantiate it, first or second activity.

    2. Static fields are also called class fields, because they are accessed via class not via object instance. The result is that, in case of static fields, you have always only one instance, e.g. MyClass.someField is available in whole app and there is only one of it.

    3. It uses memory (RAM) as opposed to data in a file (uses flash storage). But, at some point you need to have it in memory, so it uses this memory in any case.

    4. Yes, if you only need it temporarily, you can set the field to null after you no longer need it and the memory will be freed (eventually, when gc runs).

    BTW, there are several options to share data inside the app.:

    1. Pass data between activities via Intent.setExtra()/Intent.getXXXExtra()
    2. A class with static variables
    3. Via named Application class, which is single-instance and alive throughout app lifecycle
    4. Shared preferences
    5. Database
    6. Internal storage
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I am getting index out of bounds error in my code. From Activity:
Hey guys, I am using a hash_map to relate strings to one another, with
Hey all. I'm working on a project for school where I need to pass
Hey i have a situation in which i need to pass some variable value
Hey I am looking for a way to extract a string from another string.
Hey I've been making a quiz on php and mysql... I've used the CURRENT_TIMESTAMP
Hey, I've been developing an application in the windows console with Java, and want
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey guys here is my question. im using JCombobox. if a student have CB
* *Hey i was working on an application which converts any basenumber like (2,8,10,16,etc)

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.