Java Array Dump dump(T[] from, T[] to)

Here you can find the source of dump(T[] from, T[] to)

Description

Replaces all the data in to with from without making modifications to the array being dumped.

License

Open Source License

Parameter

Parameter Description
from the data array to dump from.
to the data array to dump to.

Exception

Parameter Description
IllegalArgumentException if the arrays are not equal in length.

Declaration

public static <T> void dump(T[] from, T[] to) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w  w w  .j  a v  a2 s.  c om*/
     * Replaces all the data in {@code to} with {@code from} without making
     * modifications to the array being dumped. References are held to all of
     * the dumped Objects.
     * 
     * @param from
     *            the data array to dump from.
     * @param to
     *            the data array to dump to.
     * @throws IllegalArgumentException
     *             if the arrays are not equal in length.
     */
    public static <T> void dump(T[] from, T[] to) {
        if (from.length != to.length)
            throw new IllegalArgumentException("Arrays must be equal in size!");
        for (int i = 0; i < from.length; i++)
            to[i] = from[i];
    }

    /**
     * Replaces all the data in {@code to} with {@code from} without making
     * modifications to the array being dumped. No references are held to the
     * dumped data since {@code int} is a primitive type.
     * 
     * @param from
     *            the data array to dump from.
     * @param to
     *            the data array to dump to.
     * @throws IllegalArgumentException
     *             if the arrays are not equal in length.
     */
    public static void dump(int[] from, int[] to) {
        if (from.length != to.length)
            throw new IllegalArgumentException("Arrays must be equal in size!");
        for (int i = 0; i < from.length; i++)
            to[i] = from[i];
    }
}

Related

  1. dump(double[][] a)
  2. dump(final StringBuilder buffer, final byte[] data, final int offset, final int length)
  3. dump(String name, byte[] in)
  4. dump(String t, String[] arr)
  5. dump_octets(byte[] oct)
  6. dump_strarr(String[] arr, String doc)
  7. dumpArray(final float[] array, final int maxElemsPerLine)
  8. dumpArray(String msg, float[][] A, int x1, int x2, int y1, int y2)