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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:48:29+00:00 2026-06-05T06:48:29+00:00

I am using trying to use the toString(int[]) method, but I think I am

  • 0

I am using trying to use the toString(int[]) method, but I think I am doing it wrong:

http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Arrays.html#toString(int%5B%5D)

My code:

int[] array = new int[lnr.getLineNumber() + 1];
int i = 0;

System.out.println(array.toString());

The output is:

[I@23fc4bec

Also I tried printing like this, but:

System.out.println(new String().toString(array));  // **error on next line**
The method toString() in the type String is not applicable for the arguments (int[])

I took this code out of bigger and more complex code, but I can add it if needed. But this should give general information.

I am looking for output, like in Oracle’s documentation:

The string representation consists of a list of the array’s elements, enclosed in square brackets (“[]”). Adjacent elements are separated by the characters “, ” (a comma followed by a space).

  • 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-05T06:48:30+00:00Added an answer on June 5, 2026 at 6:48 am

    What you want is the Arrays.toString(int[]) method:

    import java.util.Arrays;
    
    int[] array = new int[lnr.getLineNumber() + 1];
    int i = 0;
    
    ..      
    
    System.out.println(Arrays.toString(array));
    

    There is a static Arrays.toString helper method for every different primitive java type; the one for int[] says this:

    public static String toString(int[] a)
    

    Returns a string representation of the contents of the specified array. The string representation consists of a list of the array’s elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings as by String.valueOf(int). Returns "null" if a is null.

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

Sidebar

Related Questions

I was trying use svn to find a checkin using svn log, but it
I am trying to upload file on HTTP server using POST but when I
I'm using (trying to use) jQuery to add a class to the first paragraph
Trying to use a php generating the email address using the ID eg: peopleID
Hi All: Trying to use Memcached using BeIT.Memcached c# client. My config entry: <add
Trying to use the following demo example, using the 80px x 80px snap to
I'm trying to use redis with multidimensional array by using HMSET. My array looks
I am trying to use python for address verification using CDYNE service. I used
I am trying to use hSetBuffering in a Haskell program using GHC 6.10. When
I was trying to use the function glMultiDrawElements while studying OpenGL (using red book)

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.