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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:42:38+00:00 2026-06-15T14:42:38+00:00

String[] array = {a,c,b}; ArrayList<String> list = new ArrayList<String>(); list.add(a); list.add(b); list.add(c); System.out.println(array); System.out.println(list);

  • 0
    String[] array = {"a","c","b"};
    ArrayList<String> list = new ArrayList<String>();
    list.add("a");
    list.add("b");
    list.add("c");
    System.out.println(array);
    System.out.println(list);

For list [a, b, c] is output while for array some address is output. When we want to output the array values, we can use Arrays.toString(array); which works just like list.

I just wonder why we can’t call toString() directly on array to get the values. Isn’t it more intuitive and convenient to do so? What results in the different treatments on Array and ArrayList?

  • 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-15T14:42:39+00:00Added an answer on June 15, 2026 at 2:42 pm

    The main difference between an array and an arraylist is that an arraylist is a class that is written in Java and has its own implementation (including the decision to override toString) whereas arrays are part of the language specification itself. In particular, the JLS 10.7 states:

    The members of an array type are all of the following:

    • The public final field length
    • The public method clone, which overrides the method of the same name in class Object and throws no checked exceptions.
    • All the members inherited from class Object; the only method of Object that is not inherited is its clone method.

    In other words the language specification prevents the toString method of an array to be overriden and it therefore uses the default implementation defined in Object which prints the class name and hashcode.

    Why this decision has been made is a question that should probably be asked to the designers of the language…

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

Sidebar

Related Questions

String a []= {null,null,null,null,null}; //add array to arraylist ArrayList<Object> choice = new ArrayList<Object>(Arrays.asList(a)); System.out.println(choice.size());
System.out.println(ganzeZeile[26]); System.out.println(filter.get(11)); System.out.println(ganzeZeile[26].contains(filter.get(11))); ganzeZeile is an array of Strings. filter is an ArrayList of
Consider this sample code: List<String> myList = new ArrayList<String>(7); myList.add(5, Hello); myList.removeAll(Collections.singleton(null)); System.out.println(myList.size() +
I have hashtbles in array list. List<Hashtable<String, String>> info = new ArrayList<Hashtable<String, String>>(); Hashtable<String,
I need to serialize ArrayList<String> arr=new ArrayList<String>(); on server and then send this array
I have an ArrayList of type String that contain certain values. I want to
private List<String> longStr = new java.util.ArrayList<String>(); private List aList = null; private String []
I have an array of strings. How can I convert it to System.Collections.ArrayList?
Is there a way to use ArrayList() method to add strings to an array
I got a string array and values are as follows sNames[0] = Root |

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.