Skip to content

Instantly share code, notes, and snippets.

@justdoit0823
Created June 25, 2020 05:31
Show Gist options
  • Save justdoit0823/42c68f08ec5b13823dc988195fbf0063 to your computer and use it in GitHub Desktop.
Save justdoit0823/42c68f08ec5b13823dc988195fbf0063 to your computer and use it in GitHub Desktop.
Print java primitive type presentation.
import java.util.Arrays;
import java.util.List;
public class PrimitiveType {
public static void main(String[] args) {
byte[] x = new byte[]{1};
char[] y = new char[]{1, 2};
int[] z = new int[]{1};
long[] j = new long[]{1L};
float[] k = new float[]{1.0f};
double[] l = new double[]{1.0d};
String[] m = new String[]{""};
Integer[] o = new Integer[]{Integer.valueOf(12)};
List<Integer> p = Arrays.asList(Integer.valueOf(12));
System.out.println("byte array type: " + x.getClass());
System.out.println("char array type: " + y.getClass());
System.out.println("int array type: " + z.getClass());
System.out.println("long array type: " + j.getClass());
System.out.println("float array type: " + k.getClass());
System.out.println("double array type: " + l.getClass());
System.out.println("string array type: " + m.getClass());
System.out.println("integer array type: " + o.getClass());
System.out.println("integer list type: " + p.getClass());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment