Java int转long
时间: 2023-11-07 11:04:59 浏览: 171
java int转byte和long转byte的方法
Java中,int类型可以自动转换为long类型,而long类型需要强制转换为int类型。具体代码如下:
int i = 10;
long l = i; // int自动转换为long
long l = 1234;
int i = (int) l; // long需要使用强制转换为int
所以,Java中int转换为long是自动的,而long转换为int需要进行强制转换。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Java中int(Integer)类型与long(Long)类型数据的相互转化](https://blog.csdn.net/weixin_42346767/article/details/85067398)[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%"]
- *3* [java int转byte和long转byte的方法](https://download.csdn.net/download/weixin_38642636/12792685)[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 ]
阅读全文