How to cast an Object to an int

后端 未结 19 1609
长情又很酷
长情又很酷 2020-11-27 09:58

How can I cast an Object to an int in java?

相关标签:
19条回答
  • 2020-11-27 10:33

    I use a one-liner when processing data from GSON:

    int i = object != null ? Double.valueOf(object.toString()).intValue() : 0;
    
    0 讨论(0)
提交回复
热议问题