0% found this document useful (0 votes)
2 views1 page

Java Program: Convert Array to String

The document contains a Java program that defines a method to convert a 2D array into a string representation. It utilizes the Arrays.toString() method to print each row of the array. The main method initializes a sample 2D array and calls the conversion method, resulting in the output of each row as a string.

Uploaded by

xomopa5413
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Java Program: Convert Array to String

The document contains a Java program that defines a method to convert a 2D array into a string representation. It utilizes the Arrays.toString() method to print each row of the array. The main method initializes a sample 2D array and calls the conversion method, resulting in the output of each row as a string.

Uploaded by

xomopa5413
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

3.

Program on array to string


import [Link].*;
class array {

public static void convertToString(int arr[][])


{
for (int n = 0 ; n < [Link] ; n++)
{
[Link]([Link](arr[n]));
}

public static void main(String args[])


{
int arr[][] = { { 5,2, 9 },
{ 1, 4, 7 },
{ 8,4, 5 } };
convertToString(arr);
}
}

Output:-
[5,2, 9]
[1, 4, 7]
[8,4, 5]

You might also like