long怎么转int
时间: 2023-11-17 14:05:00 浏览: 101
long可以通过多种方式转换为int。一种方式是通过强制类型转换,将long类型直接转换为int类型,如将long变量赋值给int变量时使用`(int)`进行转换。另一种方式是通过调用`intValue()`方法,将Long对象转换为int类型。第三种方式是先将long转换为字符串,然后再将字符串转换为Integer对象。可以使用`Integer.parseInt(String str)`方法将字符串转换为int类型。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [long型转换为int型](https://blog.csdn.net/weixin_52714188/article/details/119895217)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [long(Long)与int(Integer)之间的转换](https://blog.csdn.net/windy135/article/details/89136173)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文