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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:16:28+00:00 2026-06-15T13:16:28+00:00

In my program, I’m making use of an ArrayList of ArrayList of booleans. I

  • 0

In my program, I’m making use of an ArrayList of ArrayList of booleans. I need these values carried from class to class and I’ve been doing so by simply making it static.

But I’m getting wind that this might be in bad taste. I was thinking that the best way to do without would be to make an object (a top-level one) with that collection as the central focus, probably with some methods to accompany this.

So my questions:

  1. Is this better?
  2. How do I keep one instance of the top-level object throughout the application so my values can transfer? I’m thinking a private constructor and static methods. Or should I just go with public fields? What is the approved method?
  • 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-15T13:16:30+00:00Added an answer on June 15, 2026 at 1:16 pm

    – If you don’t want to go with static ArrayList, then you can make a class Singleton and place that ArrayList into that class.

    Eg:

    public class Test{
    
      private ArrayList<String> arr = new ArrayList<String>();
    
      private static Test uniqueInstance = new Test();
    
      private Test{}      // Make constructor Private
    
      public static Test getInstance(){
    
        return uniqueInstance;
    
    
       }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My program uses the CUDA Radix Sort Class. After an update from CUDA 4.0
The program I'm making will need to show many statuses and websites information. I
program : testblocks.pl #!/usr/bin/perl use strict; use warnings; print Hi; BEGIN { warn BEGIN;
Program :main.cpp struct X { int x; }; export template <class T> T const&
My program exits when main function tries to run some class (Rock) more than
Simple program from DEITLE's book , read 5 integers and the program should print
Program I'm making has a simple configuration file looking something like this. @overlays =
My program is to print the queue of information from a file but i
I am doing a simple coin flipping experiment for class that involves flipping a
My program is fetching messages from a database, which contains English, German and several

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.