If you just want to know if an object is an instance of or extends a certain class, or implements a certain interface, you can use the instanceof keyword.
public void myMethod(Object obj) {
if (obj instanceof String) {
System.out.println("It's a String");
}
else {
System.out.println("It's not a String");
}
}
https://coderanch.com/t/404450/java/type-object
반응형
'Backend > Java&Spring Framework' 카테고리의 다른 글
[JAVA]java.net.UnknownHostException: Unable to resolve host : No address associated with hostname (0) | 2016.08.20 |
---|---|
JAVA8 | lamda (0) | 2016.08.18 |
spring + mybatis + ppas error message 2 (0) | 2015.07.14 |
spring + mybatis + ppas error message 1 (0) | 2015.07.14 |
ppas (0) | 2015.07.09 |