Java Array Output printArray(int arr[])

Here you can find the source of printArray(int arr[])

Description

print Array

License

Open Source License

Declaration

public static String printArray(int arr[]) 

Method Source Code

//package com.java2s;
/*//from  www .j  a va 2s .co m
 *  RTIbuilder
 *  Copyright (C) 2008-11  Universidade do Minho and Cultural Heritage Imaging
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3 as published
 *  by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static String printArray(int arr[]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i] + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(float arr[]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i] + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(double arr[]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i] + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(long arr[]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i] + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(String arr[]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i] + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(boolean arr[]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i] + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(int arr[][]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += printArray(arr[i]) + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(float arr[][]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i] + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(double arr[][]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += printArray(arr[i]) + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(long arr[][]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += printArray(arr[i]) + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(String arr[][]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += printArray(arr[i]) + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }

    public static String printArray(boolean arr[][]) {
        String ret = "[ ";
        for (int i = 0; i < arr.length; i++) {
            ret += printArray(arr[i]) + ", ";
        }
        return ret.substring(0, ret.length() - 2) + " ]";
    }
}

Related

  1. printArray(double[][] in)
  2. printArray(double[][] in)
  3. printarray(final int[] a)
  4. printArray(final Object[] array, int indent)
  5. printArray(float[] arr)
  6. printArray(int[] arr)
  7. printArray(int[] array)
  8. printArray(int[][] array, String arrayLabel, String rowLabel, String columnLabel)
  9. printArray(int[][] num)