这篇文章主要介绍了Java如何把int类型转换成byte,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

01.代码如下:

package TIANPAN;

/**
 * 此处为文档注释
 *
 * @author 田攀 微信382477247
 */
public class TestDemo {
  public static void main(String[] args) {
    int num = 130;        // 此范围超过了byte定义
    byte x = (byte) num;      // 由int变为byte
    System.out.println(x);
  }
}

02.效果如下: