Java ArrayList Print printArrayList(ArrayList arr)

Here you can find the source of printArrayList(ArrayList arr)

Description

Prints out the ArrayList to standard output.

License

Open Source License

Parameter

Parameter Description
arr An ArrayList of double values.

Declaration

public static void printArrayList(ArrayList arr) 

Method Source Code

//package com.java2s;
/**/* w w w . j  a v a  2 s .  c o m*/
 * Hub Miner: a hubness-aware machine learning experimentation library.
 * Copyright (C) 2014  Nenad Tomasev. Email: nenad.tomasev at gmail.com
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * 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/>.
 */

import java.util.ArrayList;

public class Main {
    /**
     * Prints out the ArrayList to standard output.
     *
     * @param arr An ArrayList of double values.
     */
    public static void printArrayList(ArrayList arr) {
        if (arr == null) {
            System.out.println("Null ArrayList.");
            return;
        }
        if (arr.isEmpty()) {
            System.out.println("Empty ArrayList");
            return;
        }
        for (int i = 0; i < arr.size() - 1; i++) {
            System.out.print(arr.get(i) + " ");
        }
        System.out.print(arr.get(arr.size() - 1));
        System.out.println();
    }
}

Related

  1. print(ArrayList[] al)
  2. print(ArrayList lines, int targetColumn)
  3. print(ArrayList tokens, String symbol)
  4. printArray(ArrayList array)
  5. printArrayArray(ArrayList> matrix)
  6. printArrayList(ArrayList set)
  7. printArrayList(ArrayList list)
  8. printArrayList(ArrayList _array)
  9. printArrayListInt(ArrayList list)