Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Converts to primitive array.
     */
    public static byte[] values(Byte[] array) {
        byte[] dest = new byte[array.length];
        for (int i = 0; i < array.length; i++) {
            Byte v = array[i];
            if (v != null) {
                dest[i] = v.byteValue();
            }
        }
        return dest;
    }

    /**
     * Converts to primitive array.
     */
    public static char[] values(Character[] array) {
        char[] dest = new char[array.length];
        for (int i = 0; i < array.length; i++) {
            Character v = array[i];
            if (v != null) {
                dest[i] = v.charValue();
            }
        }
        return dest;
    }

    /**
     * Converts to primitive array.
     */
    public static short[] values(Short[] array) {
        short[] dest = new short[array.length];
        for (int i = 0; i < array.length; i++) {
            Short v = array[i];
            if (v != null) {
                dest[i] = v.shortValue();
            }
        }
        return dest;
    }

    /**
     * Converts to primitive array.
     */
    public static int[] values(Integer[] array) {
        int[] dest = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            Integer v = array[i];
            if (v != null) {
                dest[i] = v.intValue();
            }
        }
        return dest;
    }

    /**
     * Converts to primitive array.
     */
    public static long[] values(Long[] array) {
        long[] dest = new long[array.length];
        for (int i = 0; i < array.length; i++) {
            Long v = array[i];
            if (v != null) {
                dest[i] = v.longValue();
            }
        }
        return dest;
    }

    /**
     * Converts to primitive array.
     */
    public static float[] values(Float[] array) {
        float[] dest = new float[array.length];
        for (int i = 0; i < array.length; i++) {
            Float v = array[i];
            if (v != null) {
                dest[i] = v.floatValue();
            }
        }
        return dest;
    }

    /**
     * Converts to primitive array.
     */
    public static double[] values(Double[] array) {
        double[] dest = new double[array.length];
        for (int i = 0; i < array.length; i++) {
            Double v = array[i];
            if (v != null) {
                dest[i] = v.doubleValue();
            }
        }
        return dest;
    }

    /**
     * Converts to primitive array.
     */
    public static boolean[] values(Boolean[] array) {
        boolean[] dest = new boolean[array.length];
        for (int i = 0; i < array.length; i++) {
            Boolean v = array[i];
            if (v != null) {
                dest[i] = v.booleanValue();
            }
        }
        return dest;
    }
}