當前位置:編程學習大全網 - 網站源碼 - Java有沒有類似於typedef這樣的關鍵字?謝謝

Java有沒有類似於typedef這樣的關鍵字?謝謝

有:instanceof

public static void main(String[] args) {

typedOf("123");

typedOf(true);

typedOf(1);

typedOf(1.1);

}

public static void typedOf(Object obj){

if (obj instanceof String) {

System.out.println("obj is String");

}else if(obj instanceof Boolean) {

System.out.println("obj is Boolean");

}else if(obj instanceof Integer) {

System.out.println("obj is Integer");

}else{

System.out.println("其他類型");

}

}

結果:

obj is String

obj is Boolean

obj is Integer

其他類型

  • 上一篇:為什麽說印尼燕窩比較好
  • 下一篇:龍芯3A筆記本性能評價。不知哪位用過剛出的龍芯3A筆記本,本人想入手,不知它運行壹些仿真軟件如MATLAB...
  • copyright 2024編程學習大全網