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.

Answer from Sbodd on Stack Overflow
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java string โ€บ array to string conversions
Array to String Conversions | Baeldung
June 10, 2026 - The default implementation of the toString() method on an array returns something like Ljava.lang.String;@74a10858 which only informs us of the objectโ€™s type and hash code. However, the java.util.Arrays utility class supports array and string ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java โ€บ util โ€บ arrays_tostring_int.htm
Java.util.Arrays.toString(int[ ]) Method
package com.tutorialspoint; import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { // initializing int array int[] i1 = new int[] { 33, 12, 98 }; // let us print all the elements available in list ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ arrays-tostring-in-java-with-examples
Arrays.toString() in Java with Examples - GeeksforGeeks
Java ยท import java.util.Arrays; public class ArrayToString { public static void main(String[] args) { // create an integer array int[] n = {1, 2, 3, 4}; // print the array using // Arrays.toString() System.out.println(Arrays.toString(n)); } ...
Published: April 14, 2026
๐ŸŒ
Techie Delight
techiedelight.com โ€บ home โ€บ java โ€บ convert int array to string array in java
Convert int array to string array in Java | Techie Delight
July 7, 2026 - ... Convert the specified primitive array to a IntStream using Arrays.stream() or IntStream.of() method. Convert each element of the stream to a string using IntStream.mapToObj() method.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ examples โ€บ convert-int-type-variables-to-string
Java Program to convert int type variables to String | Vultr Docs
November 25, 2024 - ... int[] numbers = {10, 20, 30, 40}; String[] stringNumbers = Arrays.stream(numbers) .mapToObj(String::valueOf) .toArray(String[]::new); for (String s : stringNumbers) { System.out.println(s); } Explain Code ยท This example demonstrates how ...
๐ŸŒ
Codemia
codemia.io โ€บ home โ€บ knowledge hub โ€บ how to convert an int array to string with tostring method in java
How to convert an int array to String with toString method in Java | Codemia
July 31, 2025 - Converting an integer array to a string representation is a common requirement when dealing with data display and logging. In Java, this can be accomplished using the toString method from the Java API. Although the toString method is not directly applicable to arrays, the Arrays utility class ...
Find elsewhere
๐ŸŒ
Java67
java67.com โ€บ 2014 โ€บ 09 โ€บ how-to-convert-array-to-string-in-java-example.html
How to Convert or Print Array to String in Java? Example Tutorial | Java67
Though you can convert an array to String by simply calling their toString() method, you will not get any meaningful value. If you convert an Integer array to a String, you will get something like I@4fee225 due to the default implementation ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ how-to-convert-an-array-to-string-in-java
How to Convert an Array to String in Java? - GeeksforGeeks
July 12, 2025 - ... // Java Program to convert ... { 'g', 'e', 'e', 'k', 's' }; double[] arr3 = new double[] { 1, 2, 3, 4 }; int[] arr4 = new int[] { 1, 2, 3, 4 }; Object[] arr5 = new Object[] { 1, 2, 3, 4 }; System.out.println(""+ ...
๐ŸŒ
CodeGym
codegym.cc โ€บ java blog โ€บ strings in java โ€บ array to string in java
Array to String in Java
November 27, 2023 - Sometimes, you might need a bit more control over how you convert the array to string. Maybe you're not a fan of those square brackets, or you need a specific separator between elements. In such cases, Java's String.join() and good old loops come to the rescue.
๐ŸŒ
Quora
quora.com โ€บ How-do-you-convert-an-integer-array-into-a-string-array-in-the-Java-programming-language
How to convert an integer array into a string array in the Java programming language - Quora
Answer: To convert an integer array into a string array in Java, you can iterate through each element of the integer array and convert each integer to its corresponding string representation. You can achieve this using the [code ]String.valueOf()[/code] method or by concatenating the integer with...
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java streams โ€บ mapping an array of integers to strings using java streams
Mapping an Array of Integers to Strings Using Java Streams | Baeldung
January 8, 2024 - Another potential use case is converting our integer array into a single String. We can reuse much of the above code for this along with Stream.collect() to reduce the Stream into a String. The collect() method is versatile and lets us terminate our Streams into a wide range of types.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ array to string in java
Array to String In Java | Scaler Topics
June 2, 2024 - Here in this program, the StringUtils.join(names,โ€œโ€) method takes two arguments first is the name of the array here it is โ€œnamesโ€ and the second argument is the delimiter, a delimiter is used between two elements when joining them together, in our example, the delimiter used is a " ...
๐ŸŒ
YouTube
youtube.com โ€บ watch
String Array To String || Integer Array To Integer || Mini Java Interview Questions Series - YouTube
String Array To String || Integer Array To Integer || Mini Java Interview Questions SeriesSchedule a meeting in case of any queries/guidance/counselling:http...
Published: July 29, 2022
๐ŸŒ
Medium
medium.com โ€บ javarevisited โ€บ nuanced-string-joining-in-java-7db547c331d0
Nuanced String Joining in Java | Javarevisited
April 23, 2024 - Our problem today will start with the array of Integers values from 1 to 5 and converted them to a String starting with a โ€œ*โ€, separating elements with โ€œ*, *โ€ and then finishing with a โ€œ*โ€.
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ array-to-string-java
Mastering Array to String Conversion in Java
February 27, 2024 - Many developers find this task a bit tricky, but Java, like a skilled craftsman, is fully capable of molding arrays into strings.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ different-ways-for-integer-to-string-conversions-in-java
Java Convert int to String | How to Convert an Integer into a String - GeeksforGeeks
April 9, 2025 - ... // Java Program to Illustrate ... args[]) { // Custom integer values int a = 1234; int b = -1234; // Concatenating with empty strings String str1 = "" + a; String str2 = "" + b; // Printing the concatenated strings ...