How to cast an Object to an int

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

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

19条回答
  •  被撕碎了的回忆
    2020-11-27 10:09

    I guess you're wondering why C or C++ lets you manipulate an object pointer like a number, but you can't manipulate an object reference in Java the same way.

    Object references in Java aren't like pointers in C or C++... Pointers basically are integers and you can manipulate them like any other int. References are intentionally a more concrete abstraction and cannot be manipulated the way pointers can.

提交回复
热议问题