Dark Horse programmer--java--converts an int array into a string

Source: Internet
Author: User

Convert an int array to a string

and output it on the control table.

Converts an int  array to a string public class Inttostringdemo {public static void main (string[] args) {//TODO auto-generated Metho D stub//defines an array of type int int[] I ={4,5,8,6,5,8,7,4,5};//call a custom method to convert the method of an int array to a string Tostringmethod (i); private static void Tostringmethod (int[] arr) {//Custom one character buffer, StringBuilder sb = new StringBuilder (); Sb.append ("[");//Traverse I An NT array and converts the elements in an int array into strings stored in the character buffer to go for (int i=0;i<arr.length;i++) {if (i!=arr.length-1)    sb.append (arr[i]+ ","); Elsesb.append (arr[i]+ "]");} System.out.println (SB);}}

To run the program:

Dark Horse programmer--java--converts an int array into a string

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.