How to check if the value is integer in java? [duplicate]
问题 This question already has answers here : Determine if object is integer (3 answers) Closed 2 years ago . I'm using some API by restTemplate. The API returns a key whose type is integer. But I'm not sure of that value, so I want to check whether the key is really an integer or not. I think it might be a string. What is the best way of checking if the value is really integer? added: I mean that some API might return value like below. {id : 10} or {id : "10"} 回答1: Object x = someApi(); if (x