/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { int intVal = 3; long longVal = 2; double doubleVal = 3.6d; float floatVal = 5.3f; MyClass valMyClass = new MyClass(); char charVal = 222; /* adicionado conforme comentário de @Piovezan */ boolean booleanVal = true; /* adicionado conforme comentário de @Piovezan */ printIsNumber(intVal); printIsNumber(longVal); printIsNumber(doubleVal); printIsNumber(floatVal); printIsNumber(valInt); printIsNumber(valLong); printIsNumber(valDouble); printIsNumber(valFloat); printIsNumber(valString); printIsNumber(valMyClass); printIsNumber(valObj); printIsNumber(charVal); /* adicionado conforme comentário de @Piovezan */ printIsNumber(valChar); /* adicionado conforme comentário de @Piovezan */ printIsNumber(booleanVal); /* adicionado conforme comentário de @Piovezan */ printIsNumber(valBoolean); /* adicionado conforme comentário de @Piovezan */ } } } public static class MyClass{ } }
Standard input is empty
class java.lang.Integer, val: 3 is number: true class java.lang.Long, val: 2 is number: true class java.lang.Double, val: 3.6 is number: true class java.lang.Float, val: 5.3 is number: true class java.lang.Integer, val: 5 is number: true class java.lang.Long, val: 68 is number: true class java.lang.Double, val: 23.5 is number: true class java.lang.Float, val: 34.7 is number: true class java.lang.String, val: Teste is number: false class Ideone$MyClass, val: Ideone$MyClass@52e922 is number: false class java.lang.Object, val: java.lang.Object@25154f is number: false class java.lang.Character, val: Þ is number: true class java.lang.Character, val: Þ is number: true class java.lang.Boolean, val: true is number: false class java.lang.Boolean, val: false is number: false