fork download
  1. public final class Main {
  2.  
  3. public static Class<Boolean> typeof(final boolean expr) {
  4. return Boolean.TYPE;
  5. }
  6.  
  7. public static Class<Character> typeof(final char expr) {
  8. return Character.TYPE;
  9. }
  10.  
  11. public static Class<Byte> typeof(final byte expr) {
  12. return Byte.TYPE;
  13. }
  14.  
  15. public static Class<Short> typeof(final short expr) {
  16. return Short.TYPE;
  17. }
  18.  
  19. public static Class<Integer> typeof(final int expr) {
  20. return Integer.TYPE;
  21. }
  22.  
  23. public static Class<Long> typeof(final long expr) {
  24. return Long.TYPE;
  25. }
  26.  
  27. public static Class<Float> typeof(final float expr) {
  28. return Float.TYPE;
  29. }
  30.  
  31. public static Class<Double> typeof(final double expr) {
  32. return Double.TYPE;
  33. }
  34.  
  35. public static Class<?> typeof(final Object expr) {
  36. return expr == null ? null : expr.getClass();
  37. }
  38.  
  39. public static void main(final String[] argv) {
  40. System.out.println(typeof(500 * 3 - 2));
  41. System.out.println(typeof(50 % 3L));
  42. System.out.println(typeof(new String()));
  43. System.out.println(typeof(argv));
  44. System.out.println(typeof(argv.length));
  45. System.out.println(typeof(4f));
  46. System.out.println(typeof(null));
  47. }
  48. }
Success #stdin #stdout 0.06s 215488KB
stdin
Standard input is empty
stdout
int
long
class java.lang.String
class [Ljava.lang.String;
int
float
null