ADVERTISEMENT
ADVERTISEMENT

Java program to convert an integer array into the string using the '+' operator

Given/input an integer array, we have to convert it into the string using the "+" operator.
Submitted by Nidhi, on March 15, 2022

Problem Solution:

In this program, we will create an array of integers. Then we will convert the array into a string.

Program/Source Code:

The source code to convert an integer array into the string using the "+" operator is given below. The given program is compiled and executed successfully.

// Java program to convert an integer array into 
// the string using the "+" operator

import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    int i;
    String str = "";
    int[] arr = {53, 7, 64, 1, 9};

    for (i = 0; i < arr.length; i++) {
      str += arr[i];
    }

    System.out.println(str);
  }
}

Output:

5376419

Explanation:

In the above program, we imported java.util.Scanner to read input from the user. And, created a Main class that contains a method main().

The main() method is the entry point for the program, here we created an integer array arr and converted the created array into the string using concatenation, and printed the result.

Java Conversion Programs »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.