How to cast an Object to an int

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

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

19条回答
  •  难免孤独
    2020-11-27 10:23

    If you mean cast a String to int, use Integer.valueOf("123").

    You can't cast most other Objects to int though, because they wont have an int value. E.g. an XmlDocument has no int value.

提交回复
热议问题