Est-ce le type de VB? Je le voulais, mais je ne semblais rien avoir, alors je l'ai fait.
Ce n'est peut-être pas pour un usage professionnel, mais je le voulais pour apprendre. [Langage de programmation Java 4e édition](https://www.amazon.co.jp/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83% 9F% E3% 83% B3% E3% 82% B0% E8% A8% 80% E8% AA% 9EJava-Java-% E3% 82% B1% E3% 83% B3% E3% 83% BB% E3% 82 Les exercices de la page 192 de% A2% E3% 83% BC% E3% 83% 8E% E3% 83% AB% E3% 83% 89 / dp / 4894717166).
Référence: https://stackoverflow.com/questions/3993982/how-to-check-type-of-variable-in-java
class Type {
    static String of(byte x) {
        return (x + " is a byte.");
    }
    static String of(short x) {
        return (x + " is a short.");
    }
    static String of(int x) {
        return (x + " is an int.");
    }
    static String of(float x) {
        return (x + " is a float.");
    }
    static String of(double x) {
        return (x + " is a double.");
    }
    static String of(char x) {
        return (x + " is a char.");
    }
    static String of(boolean x) {
        return (x + " is a boolean.");
    }
    static String of(Object x) {
        final String className = x.getClass().getName();
        return (x + " is instance of " + className);
    }
}
class Main {
    public static void main(String[] args) {
        Type t = new Type();
        System.out.println(Type.of(t));
    }
}
Recommended Posts