← 返回首页

Java中 long和int可以互转吗

可以的,Java中的long和int可以相互转换。

由于long类型的范围比int类型大,因此将int转换为long是安全的,而将long转换为int可能会导致数据丢失或溢出。