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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:06:09+00:00 2026-06-15T22:06:09+00:00

It seems to me like ArrayList would be easier to use in nearly every

  • 0

It seems to me like ArrayList would be easier to use in nearly every scenario, it being very versatile. Is there an instance where a String[] would be used to store inputted data? If there is such a case, there must be a drawback in ArrayList, what would that be?

Only thing that comes to mind off the top of my head would be the variety of String methods like, substring() and split(), etc.

EDIT: New to StackOverflow as well. I apologize if this was a re-post. And thanks for the formatting.

  • 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-15T22:06:10+00:00Added an answer on June 15, 2026 at 10:06 pm

    The short answer is: don’t use an array, always use an array list. The only exception to this is if you absolutely need to control the amount of memory used or you have some specific performance constraint that only String[] can support.

    In general, though, arrays are terrible to work with in an object oriented language, and almost always for the same reason: they make it very easy to break encapsulation. For example:

    public class ExampleArray {
      private final String[] strings;
    
      public ExampleArray(String... strings) { this.strings = strings; }
      public String[] getStrings() { return strings; }
    }
    

    See any problems? Yea, you need to write getStrings() like this:

    // ...
    public String[] getStrings() { return Arrays.copy(strings); }
    // ...
    

    Otherwise, some caller can get a hold of your class’ internal data and start modifying it. The only way to prevent this is to copy it every time a caller wants to see it. As opposed to the right way:

    public class ExampleList {
      private final List<String> strings;
    
      // ...
    
      public List<String> getStrings() { return Collections.unmodifiableList(strings); }
    }
    

    Now you’re not copying the data, you’re just sticking it behind an API that doesn’t allow changes. If you use the Guava Immutable* classes, even better.

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

Sidebar

Related Questions

Seems a very basic question. I've an ArrayList<Integer> al and I would like to
I'm making heavy use of ArrayList in some JSP pages. I would like to
Seems like there should be... Right now it just seems like magic that you
Seems like a standard approach for an ioc when given a scenario like (C#
Seems like it would be better if you did commit followed by merge. I'm
I would like to use this kind of Objects with json: class Message{ int
Suppose I have an ArrayList<Fruit> I would like to get all elements from this
Seems like i need some help with a project. I have a routine ,
Seems like cuke doesn't show the full error message (at least when problem occurs
Seems like this should be obvious, but how do I send arrow key presses

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.