Java Utililty Methods Integer Create

List of utility methods to do Integer Create

Description

The list of methods to do Integer Create are organized into topic(s).

Method

inttoInt(Object vo)
to Int
if (vo == null) {
    return 0;
String voStr = toString(vo);
try {
    return Integer.parseInt(voStr);
} catch (Exception e) {
return 0;
inttoInt(short leftShort, short rightShort)
to Int
int leftInt = leftShort;
int rightInt = rightShort;
return leftInt | (rightInt << 16);
intToInt(short n1, short n2)
To Int
byte[] bytes = new byte[4];
bytes[1] = (byte) (n1 & 0xff);
bytes[0] = (byte) ((n1 >> 8) & 0xff);
bytes[3] = (byte) (n2 & 0xff);
bytes[2] = (byte) ((n2 >> 8) & 0xff);
return ToInt(bytes);
inttoInt(short s0, short s1)
Returns an int built from two shorts.
return (s0 & 0xFFFF) | (s1 << 16);
inttoInt(short x, short y)
to Int
return (x << 16) | (y & 0xffff);
int[]toInt(short[] arr)
Converts an array of short values to an array of integer values.
int n = arr.length;
int[] converted = new int[n];
for (int i = 0; i < n; i++) {
    converted[i] = arr[i];
return converted;
int[]toInt(String arr, String separator)
to Int
if (arr == null || "".equals(arr)) {
    return new int[0];
String[] array = arr.split(separator);
int[] r = new int[array.length];
for (int i = 0; i < array.length; i++) {
    r[i] = Integer.parseInt(array[i]);
return r;
inttoInt(String chars)
to Int
if (chars.length() != 4) {
    throw new RuntimeException("chars should be 4 characters long");
return toInt(chars.charAt(0), chars.charAt(1), chars.charAt(2), chars.charAt(3));
inttoInt(String input, int defaultValue)
to Int
try {
    return Integer.parseInt(input);
} catch (Exception e) {
    return defaultValue;
inttoInt(String input, int offset, int length)
Converts the given string into an integer using Horner's method.
if (length == 1) {
    return input.charAt(offset) - '0';
int out = 0;
for (int i = offset + length - 1, factor = 1; i >= offset; --i, factor *= 10) {
    out += (input.charAt(i) - '0') * factor;
return out;
...