Java Utililty Methods Integer Array Convert To

List of utility methods to do Integer Array Convert To

Description

The list of methods to do Integer Array Convert To are organized into topic(s).

Method

double[]copySignedIntToDoubleArray(int[] src)

Copy an array of signed values in int, into an array of double.

Sign extension is performed.

if (src == null)
    return null;
int n = src.length;
double[] dst = new double[n];
for (int j = 0; j < n; ++j) {
    dst[j] = src[j]; 
return dst;
...
short[]copySignedIntToShortArray(int[] src)

Copy an array of signed values in int, into an array of short.

The value is truncated as necessary.

if (src == null)
    return null;
int n = src.length;
short[] dst = new short[n];
for (int j = 0; j < n; ++j) {
    dst[j] = (short) (src[j]); 
return dst;
...
intintArray2HashCode(int[] xs)
int Array Hash Code
int hc = 0;
for (int i = 0; i < xs.length; ++i) {
    hc = 31 * hc + xs[i];
return hc;
StringintArray2HexString(int[] intArray)
int Array Hex String
if (intArray == null || intArray.length <= 0) {
    return "";
StringBuilder sb = new StringBuilder();
for (int i : intArray) {
    sb.append(String.format("%04x", i));
return sb.toString();
...
Integer[]intArray2IntegerArray(int[] array, int newLength)
int Array Integer Array
Integer[] ret = new Integer[newLength];
for (int i = 0; i < ret.length; i++) {
    ret[i] = array[i];
return ret;
StringintArray2Json(int[] array)
int Array Json
if (array.length == 0)
    return "[]";
StringBuilder sb = new StringBuilder(array.length << 4);
sb.append('[');
for (int o : array) {
    sb.append(Integer.toString(o));
    sb.append(',');
sb.setCharAt(sb.length() - 1, ']');
return sb.toString();
StringintArrayToAddressString(int vals[])
int Array To Address String
StringBuilder buf = new StringBuilder();
for (int i = 0; i < vals.length; ++i) {
    buf.append(String.format("%02x", vals[i]));
return buf.toString();
StringintArrayToBits(int[] ina, int min, int max, int numBits)
Creates a bit string (0s and 1s) from an integer array.
StringBuilder buff = new StringBuilder();
for (int i = 0; i < ina.length; i++) {
    int in = ina[i];
    in = in - min;
    in = Math.min(in, max - min);
    String bits = Integer.toBinaryString(in);
    while (bits.length() < numBits)
        bits = "0" + bits;
...
char[][]intArrayToCharArray(int[][] intArray)
int Array To Char Array
char[][] result = new char[intArray.length][intArray[0].length];
for (int i = 0; i < intArray.length; i++) {
    for (int j = 0; j < intArray[0].length; j++) {
        result[i][j] = (char) intArray[i][j];
return result;
float[]intArrayToFloatArray(int[] intArray)
int Array To Float Array
float[] floatArray;
floatArray = new float[intArray.length];
for (int i = 0; i < intArray.length; i++) {
    floatArray[i] = (float) intArray[i];
return floatArray;