Integer array to String - Java java.lang

Java examples for java.lang:String Array

Description

Integer array to String

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int[] elements = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(iats(elements));
    }/* ww  w.jav  a2s. co  m*/

    /** Integer array to String */
    public static String iats(int[] elements) {
        String[] data = new String[elements.length];
        for (int i = 0; i < elements.length; i++) {
            data[i] = elements[i] + "";
        }
        return sats(data);
    }

    /** String array to String */
    public static String sats(String[] elements) {
        String result = "";
        for (int i = 0; i < elements.length; i++) {
            result += elements[i];
            if (i + 1 < elements.length)
                result += " ";
        }
        return result;
    }
}

Related Tutorials