「java」instanceof演算子を利用する方法

サンプルコード

package com.arkgame.study;

public class SampleInter {

	public static void main(String[] args) {
		Object a = 55.0;

		boolean x = a instanceof Object;
		boolean y = a instanceof Integer;
		boolean z = a instanceof Double;
		System.out.println(x);
		System.out.println(y);
		System.out.println(z);

	}

}

結果
true
false
true

Java

Posted by arkgame